jQuery Click on Desktop

Hi,

I am trying to create an initial state open for dropdown on my page using custom code however, I seem to be running into issues when I put them into Webflow.

I have read posts on the Webflow Forum as well as other forums that all go back to the same answer:
$('.dropdown-toggle').trigger('tap');

When I add this on Webflow it doesn’t seem to work at all. I have changed the trigger from ‘tap’ to ‘click’ which then works on mobile but it doesn’t work on desktop at all unless I have inspect element open.

I have tried to use so many variants of lines of code and seem to be getting nowhere - including:

Adding document ready
$(document).ready(function(){$('.dropdown-toggle').trigger('click');});

Adding time out
setTimeout(function () {$('.dropdown-toggle').trigger('click');}, 1000);

Does anyone know why it doesn’t work on Webflow but seems to work find on JSFiddle and Inspect Element. I have added a CDN although I’ve read that Webflow has that on it’s website’s already which produced no results at all.

If there are any alternative methods to get the dropdown to open through custom code on load that could possibly be worth a try?

Thanks in advanced.


This is a link to the JSFiddle that seems to work perfectly but doesn’t work at all on Webflow

Make sure you place jQuery dependent scripts in the before body close area. Webflow loads JQ right above that.

I have added all the scripts before the body close however, that still produces the same problem?

Is there a possibility of native code in Webflow that stops jQuery Click from working?

I have had no issues running jQuery on Webflow. If you want help then share a link to the published URL so the page can be inspected in a browser’s developer tools. Sharing your read-only project and a published link is a requirement for this topic category.