I have five boxes that are set to expand and collapse using the script below. While the script provides the correct functionality as it is written, I would like to set the scripting to where any expanded box will collapse when one of the other multi-state box’s button is clicked to expand. My goal is to have one box expanded at a time without the need to collapse a box by button beforehand.
Any suggestion using the current, functioning script? Thank you in advance.
$w.onReady(()=>{
$w("#readMoreButton").onClick(() => {
$w("#readMoreStatebox").changeState("expandedState");
});
$w("#readLessButton").onClick(() => {
$w("#readMoreStatebox").changeState("collapsedState");
});
$w("#readMoreButton2").onClick(() => {
$w("#readMoreStatebox2").changeState("expandedState2");
});
$w("#readLessButton2").onClick(() => {
$w("#readMoreStatebox2").changeState("collapsedState2");
});
$w("#readMoreButton3").onClick(() => {
$w("#readMoreStatebox3").changeState("expandedState3");
});
$w("#readLessButton3").onClick(() => {
$w("#readMoreStatebox3").changeState("collapsedState3");
});
$w("#readMoreButton4").onClick(() => {
$w("#readMoreStatebox4").changeState("expandedState4");
});
$w("#readLessButton4").onClick(() => {
$w("#readMoreStatebox4").changeState("collapsedState4");
});
$w("#readMoreButton5").onClick(() => {
$w("#readMoreStatebox5").changeState("expandedState5");
});
$w("#readLessButton5").onClick(() => {
$w("#readMoreStatebox5").changeState("collapsedState5");
});
});