3 ms·
IMO the important part is that the DOM API is now consistent across browsers. I don't really have any problem using document.getElementById instead of $, the is
by untog 11y ago
IMO the important part is that the DOM API is now consistent across browsers. I don't really have any problem using document.getElementById instead of $, the issue was handling events and so on. These days, addEventListener works in every browser. New additions like classList.add/classList.remove are just bonuses.
As for the chainable syntax, I'm honestly in two minds about it. It's incredibly powerful, but some of the worst JS I've ever seen has been written in endless jQuery chain statements.
- lostPixels 11y agoI found out recently how much of a nightmare removeEventListener is compared to namespaced events in jQuery.
- DonHopkins 11y agojQuery has a nice efficient event delegation mechanism, that lets you listen for events on elements that don't even exist yet, by specifying selector patterns and listening on the root element with a few global event handlers, instead of adding listeners to every leaf element as it's created. It does all the bookkeeping and event handling in one place, so it saves a lot of memory and time. So not only does it work consistently across all browsers, but it also doesn't suck! https://learn.jquery.com/events/handling-events/#binding-events-to-elements-that-don-39-t-exist-yet https://learn.jquery.com/events/handling-events/#binding-eve... https://learn.jquery.com/events/event-delegation/ https://learn.jquery.com/events/event-delegation/