How do I trigger a function with this code?

if (url === “my-specific-url”)

//I need code to trigger this function:

export function busBut_click(event, $w) {
//Add your code for this event here:
collapseAll1();
collapseAll2();
collapseAll3();
$w(’ #busStrip ‘).show();
$w(’ #busText ‘).expand();
$w(’ #busText2 ‘).expand();
//SHOWING BUTTON
$w(’ #busClick ').show(); }

Can we assume that where you have collapseAll() for 1, 2 and 3, that you actually wanted those elements, strips or containers to be collapsed on load?

To do this, simply tick the collapsed on load box in the properties panel for that element, strip or container. You can do the same with the hidden on load option in the properties panel too.

Note that hidden on load will hide the element, however it will still be taking up space on your page. Whereas if you use collapsed on load, then the element will be collapsed and not taking up any space on your page, although note that when it expands that it may push other elements down the page if they are in the way of the expanded element, strip or container etc.

See this page for more info on how elements are affected.
https://support.wix.com/en/article/corvid-how-page-layout-is-affected-when-elements-change-size

Have a read here of how to do show and hide and collapse and expand.
https://www.wix.com/corvid/reference/$w.HiddenMixin.html
https://www.wix.com/corvid/reference/$w.HiddenCollapsedElement.html

For this line below, you will need to add an onClick event to the element in the properties panel.

 export function busBut_click(event, $w) { 

@j4yw4lk , I hope you understand that if (url === “my-specific-url”) is only an example, and you have to replace the variable and the string and to open a block where you call the function you want to execute…

Yes, the functions of collapse are all necessary. I’m only trying to run that function when someone clicks a particular link. The page defaults to hide everything, but with the link I wanted it to default to run that function. Your instructions lost me a bit, sorry.

I’m aware. I’m just trying to find code to run a function when someone clicks a specific url I input so that it changes the default to run a function.