How can we trigger interaction via jquery?

Hey guys, how do we trigger interactions (already on a button with jquery).
Imagine I have a click interaction on a button like .search-btn.

Physically Clicking on it triggers the interaction.

But when I do:

$(‘.search-btn’).click();

It does not work.

The click however is working as I can get an alert, or .remove the button, but the interaction is not being triggered.


Here is my site Read-Only: LINK
(how to share your site Read-Only link)

The script-click on an interaction click-trigger is the approach I always use.
I use vanilla JS. It seems unlikely that jquery would click any differently, but try a standard JS click just in case.

Surprisingly, that worked, but the jquery click didn’t. Thanks a ton!

So, GPT has an interesting explanation…

jQuery’s .click() does not trigger native click events like JavaScript’s .click() method. It only triggers jQuery’s own event handling mechanisms. If the click event is expected to interact with native browser behaviors (e.g., form submission), jQuery .click() might not trigger those.

1 Like