Reputation: 13
I wonder if there's a way to combine a JS selector with jQuery functions methods like that:
document.getElementsByClassName("example").on("click", function() {
...
});
Upvotes: 1
Views: 94
Reputation: 414036
You can pass your node list to the jQuery constructor:
$(document.getElementsByClassName("example")).on("click", function() {
// ...
});
I don't know for sure how long jQuery has recognized when node lists are passed to the constructor, but it seems to work now.
Upvotes: 1