Hi,
I'm a Wix beginner. I understand the onClick Expand/Collapse. My question is:
Is there code to make anything collapse when clicking something else?
Example, 3 buttons show text. When clicking one button, do I need to put the code for both the other 2 buttons that would need to collapse the previous text or is there 1 piece of code that will collapse anything thats open so that it will show the new expanded text?
In otherwords, do I need code for button #1 to collapse button #2 and more code for it to close button #3? Or, is there a code to collapse anything it finds open instead of having to specify 1,2, or 3?
Thanks for anyones help :)
Greetings,
To hide all elements of the same type you can do this:
$w("Image").hide();
This takes all elements on the page with the Image type and hides it.
Here is how you get the type of the element if you are confused:
let myElement = $w("#myElement"); let elementType = myElement.type; // "$w.Type"
Here is some more information from the Wix API.
Best,
Majd
Thanks Mustafa, I get that, however... my question is do I clarify it to look for any of the other buttons that have been activated and close them down first before it activates itself? example: when pressing button 1
it needs to check to close button 2 and button 3
and for button 2...
it needs to check to close button 1 and button 3?
What looking for is code to do something like this:
button 1...
check for ANYTHING to close... instead of having to code it to check for button 2 and then check for button 3.
Hi, As you have a button, you have to clarify what should happen inside each button onClick function. Hope this helps! Best, Mustafa