Hi.
I have certain elements that either “show” or “hide” on mouseIn or mouseOut in the desktop view. When I switch to the mobile view, I hid the elements, since hovering is not a concept for mobile views. How do I correct the code so I don’t receive code errors for the hidden elements.
Here is an example of the code on one of my pages. The code written in RED are the elements that I want to hide in mobile view. I’m not very experienced with writing code, so please make it simple.
function toggleFold(index) {
let $fold = $w('#fold' + index);
let $arrowDown = $w('#arrowDown' + index);
let $arrowRight = $w('#arrowRight' + index);
// toggle the fold at the index
if ($fold.collapsed) {
$fold.expand();
$arrowDown.show();
$arrowRight.hide();
} else {
$fold.collapse();
$arrowDown.hide();
$arrowRight.show();
}
// collapse the other folds
[1, 2, 3, 4]
.filter(idx => idx !== index)
.forEach(idx => {
$w('#fold' + idx).collapse();
})
}
export function headerBox1_click(event) {
if ($w("#fold1").collapsed) {
$w("#fold1").expand();
} else {
$w("#fold1").collapse();
}
$w('#arrowDown1').hide();
$w('#arrowRight1').show()
//Add your code for this event here:
}
export function fold1_mouseIn(event) {
$w('#fold1').expand();
$w('#arrowDown1').show();
$w('#arrowRight1').hide()
//Add your code for this event here:
}
export function fold1_mouseOut(event) {
$w('#fold1').collapse();
$w('#arrowDown1').hide();
$w('#arrowRight1').show()
//Add your code for this event here:
}
export function headerBox2_click(event) {
if ($w("#fold2").collapsed) {
$w("#fold2").expand();
} else {
$w("#fold2").collapse();
}
$w('#arrowDown2').hide();
$w('#arrowRight2').show()
//Add your code for this event here:
}
//Add your code for this event here:
export function fold2_mouseIn(event) {
$w('#fold2').expand();
$w('#arrowDown2').show();
$w('#arrowRight2').hide()
//Add your code for this event here:
}
export function fold2_mouseOut(event) {
$w('#fold2').collapse();
$w('#arrowDown2').hide();
$w('#arrowRight2').show()
//Add your code for this event here:
}
export function headerBox3_click(event) {
if ($w("#fold3").collapsed) {
$w("#fold3").expand();
} else {
$w("#fold3").collapse();
}
$w('#arrowDown3').hide();
$w('#arrowRight3').show()
//Add your code for this event here:
}
export function fold3_mouseIn(event) {
$w('#fold3').expand();
$w('#arrowDown3').show();
$w('#arrowRight3').hide()
//Add your code for this event here:
}
export function fold3_mouseOut(event) {
$w('#fold3').collapse();
$w('#arrowDown3').hide();
$w('#arrowRight3').show()
//Add your code for this event here:
}
export function headerBox4_click(event) {
if ($w("#fold4").collapsed) {
$w("#fold4").expand();
} else {
$w("#fold4").collapse();
}
$w('#arrowDown4').hide();
$w('#arrowRight4').show()
}
//Add your code for this event here:
export function fold4_mouseIn(event) {
$w('#fold4').expand();
$w('#arrowDown4').show();
$w('#arrowRight4').hide()
//Add your code for this event here:
}
export function fold4_mouseOut(event) {
$w('#fold4').collapse();
$w('#arrowDown4').hide();
$w('#arrowRight4').show()
//Add your code for this event here:
}
export function headerBox4_click_1(event) {
//Add your code for this event here:
}
Thanks so much for your help!
Johanna