|
|
|
|
|
by jackmoore
4081 days ago
|
|
DOM inconsistencies aside, a big advantage jQuery has over native API is that it is just as easy to work with multiple elements as it is single elements. Modifying your example: var d = document.querySelectorAll('div');
d = Array.prototype.slice.call(d);
d.forEach(function(el){ el.classList.add('new') });
Vesus: $('div').addClass('new');
|
|
Though with frameworks like Angular or React I'm beginning to question whether we should ever be writing code like this at all.