mmh interesting, it seems webflow doesn’t use <select> markup for its dropdowns but <div> instead. I see that when a “dropdown” is open, it has a webflow class of “w–open”. You might want to programmatically do this like so:
I’ve been trying to implement your original solution on my site but nothing seems to work. I have renamed classes and placed code in the before tag. Have there been any changes to the dropdown implementation that may have made the code obsolete? Just want all of my dropdowns to be open when the page is loaded so the content populates the space.
Hey Anthony, is it possible to set the initial state of a dropdown element to open? Other than it should behave as usual. Trying to build an accordion with the webflow dropdown elements, first one should be open initially.
You need to replace .dropdown-toggle with the class name of the toggle element. If you want to use the element ID instead you can replace the . to a #.
You will also need to put these in between <script> ... </script> tags on the custom code box
I have tired $('.dropdown-toggle').trigger('tap'); but it only seems to work on Inspector mode, tablet and mobile views. Does any one know why that’s happening or a way around this to get it working on Desktop?
Thanks for your contribution about this topic. Hower I’m having a similar issue that I can not solve. I’m having this design where the first dropdown is open and displays the active FAQ item. Do you guys know a way to initial open the dropdown on load with a collection list in it?
Hey @samliew
I tried your trick and it works for setting the first dropdown as open by default. It worked.
But there is a problem, It is not closing when I open other dropdowns.
I want it to close when I click to open any other dropdown…
How to achieve that? Please help!
its now 2023 and nothing works to target the first dropdown toggle element ID to open. I tried this but the tap function is for mobile. I tried mouseup for desktop. Neither works! Any coders that know how to make this work in 2023?
You want an initial state of open or a permanent state of open?
For a permanent state, I’d probably use CSS to force it to be visible.
For an initial state, try click(). You may also need to look at event bubbling, it depends on how and where Webflow.js event handler is attached.
Not that today this can be tricky because browser have implemented security measures to differentiate between script-clicks and user-clicks, to mitigate clickjacking as a hacking vector.
If you encounter security barriers it’s likely easier to just build your own custom nav from DIVs and interactions.
Not exactly what OP was looking for, but I just found a handy solution to have the/multiple default Dropdown /Accordion element(s) opened in the Designer for easy accessibility for editing copy while in development: