3 ms·
> Can you give us some examples of things that you're worried can't be written clearly using plain JS? Obviously everything you can do with jquery you can do wi
by padseeker 9y ago
> Can you give us some examples of things that you're worried can't be written clearly using plain JS? Obviously everything you can do with jquery you can do without jquery. Its just a library.
The not() selector for jquery is one. The closest() is another that I have used multiple times.
> What do you mean by event delegation in this context?
This is what event delegation looks like in jQuery;
$("ul#listid").( "click", "li.classThatMatters", function() {
//do something
});
How would event delegation look when selecting a child element with a specific class? Event delegation from scratch in vanilla js is longer than this.
I don't know much about query selectors. I'm going to read up on them. I suspect it handles most if not all the basic stuff jQuery does. However I suspect that are use cases that it might now.
- jayshua 9y agoIf I understood your event delegation example correctly, I would use event.target.matches inside the event handler. Not the greatest support at the moment though.