Can we use normal javascript event function on jquery document selector? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can we use normal javascript event function on jquery document selector?

Yeah i ever try it.. and it haven't got any error yet but i think it won't work, so i'm not pretty sure on this.. I just need you guys suggestion ~ also change my mind.. thx :) Check in 2 days..

14th Oct 2020, 4:55 AM
El Roy Situmorang
3 Answers
+ 6
Elroy Situmorang Ultimately... jQuery is using the native Javascript method for registering event handlers under the hood. So... as Kevin ★ so well put it, the answer is yes. It might help to think of jQuery as an extension that can wrap a given DOM node object with additional convenience methods. These convenience methods are the same on all browsers. However, the implementation will use browser specific APIs to do some work. In the past, before ES6, jQuery was more relevant with so much browser incompatibility and a limited native JS API. Fortunately, browsers today are more consistent.
14th Oct 2020, 7:42 AM
David Carroll
David Carroll - avatar
+ 5
You'll need to get back the DOM element from the jquery object. $("#el")[0].addEventListener ("click", function (){ } ) $(".els").toArray().forEach(...) I recommend you to select the Dom element by yourself and use jQuery selector only when strictly required. Plain JavaScript: document.querySelector("#el") document.querySelectorAll(".els")
14th Oct 2020, 7:14 AM
Kevin ★
+ 1
If you could link your attempt here then can be seen to help you.
14th Oct 2020, 7:11 AM
JaScript
JaScript - avatar