+ 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..
3 Réponses
+ 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.
+ 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")
+ 1
If you could link your attempt here then can be seen to help you.