Hello everybody!! I need help with a code.
I am trying to create multiple buttons that open and close different strips with content on them when each button is clicked (only tokyo and rome button).
I have this code but it doesn't work. Is there anyone who can explain what I wrote wrong?
Thank you very much
$w.onReady(function () {
$w('#tokyoCollapseButton1').onClick(() => {
toggleBox($w('#tokyoCollapsibleBox1'), $w('#tokyoPlusSign1'), $w('#tokyoMinusSign1'));
});
$w('#romeCollapseButton2').onClick(() => {
toggleBox($w('#romeCollapsibleBox2'), $w('#romePlusSign2'), $w('#romeMinusSign2'));
});
$w('#parisCollapseButton').onClick(() => {
toggleBox($w('#parisCollapsibleBox'), $w('#parisPlusSign'), $w('#parisMinusSign'));
});
});
function toggleBox(boxElement, plusSign, minusSign) {
const isCollapsed = boxElement.collapsed;
if (isCollapsed) {
plusSign.hide();
minusSign.show();
boxElement.expand();
} else {
minusSign.hide();
plusSign.show();
boxElement.collapse();
}
}
export function tokyoCollapseButton1_onClick(event) {
$w("#tokyoCollapsibleBox1").expand();
$w("#romeCollapsibleBox2").collapse();
}
export function romeCollapseButton2_onClick(event) {
$w("#romeCollapsibleBox2").expand();
$w("#romeCollapsibleBox2").collapse();
}
Can you share your site URL? sometimes you might accidentally removed the event handler: https://support.wix.com/en/article/velo-reacting-to-user-actions-using-events