Skip to content
Advertisement

Listen for jQuery Event With Vanilla JS

So I am trying to determine whether its possible to listen for events added with jQuery using vanilla JS. I found this question:

Listen to jQuery event without jQuery

which definitely answers it for version 1 of jQuery. How about version 3 however?

I have a fiddle that I have put together to test out, but I am unable to get the 1st submit to work with any version of jQuery. Am I missing something, or is the event model in jQuery 3 still not using the DOM event model?

https://jsfiddle.net/ydej5qer/1/

Here is the code in the fiddle:

HTML:

JavaScript

JavaScript:

JavaScript

Advertisement

Answer

The short answer is that this is impossible as jQuery provides an event layer over vanilla JS. That means that vanilla JS cannot talk to that added layer.

So in summary, jQuery can catch vanilla JS events, but vanilla JS cannot catch jQuery added events.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement