@Fabian_Colnaric - If you look at the page source you can see where it is loaded; right before the body close. So any JavaScript that loads jQuery needs to be in the 'before page body close" custom code area OR you could use the following anywhere with Webflow’s push function;
<script>
var Webflow = Webflow || [];
Webflow.push(function () {
// your code with JQuery
});
</script>
Got it working!
Here is Fabians code wrapped in Jeff Selsers push function (without loading jquery twice):
Ive also added Esc on the keyboard as a way to close the menu.
Remember to replace the class .close-dropdown with your own
<script>
// Close dropdown
var Webflow = Webflow || [];
Webflow.push(function () {
$(document).ready(function() {
$('.close-dropdown').on('click', function () {
$(".w-dropdown").trigger("w-close");
});
$(document).on('keydown', function (e) {
if (e.key === 'Escape') {
$(".w-dropdown").trigger("w-close");
}
});
});
});
</script>
Thank you so much!! This worked perfectly. For anyone who needs more context, replace .close-dropdown with any class on the links being clicked inside the dropdown
Hey everyone! I believe I’ve found a native solution to fix this issue.
If you’re using a dropdown, simply add a link within the dropdown by clicking the “Add Link” button. This works perfectly without the need for any additional interactions or custom code.