i want to have a default option in my sort dropdown.
i have created a script but that is not working good.
i have created a second click to close dropdown but its not working without delay, but now you see a flicker of the dropdown. also when reloading couple times the default sort click doesnt work anymore and then the click of the dropdown is only working. you will see a openend dropdown on page load
https://home-up-e82405df4902095e59a92deee54b519.webflow.io/woningaanbod
<script>
window.onload = function() {
// Click the first filter option immediately
var firstFilter = document.querySelector('.first-filter-option');
if (firstFilter) {
firstFilter.click();
}
// Delay the click on the filter_dropdown-sort by 100 milliseconds
setTimeout(function() {
var dropdownSort = document.querySelector('.filter_dropdown-sort');
if (dropdownSort) {
dropdownSort.click();
}
}, 100);
};
</script>