Quick intro to JavaScript CSS ClassLIst API

Of all the ways people have been using jQuery, one of the methods that rank high up there is jQuery's CSS class manipulation methods, which are:


These functions make it extremely easy to add, remove, and check whether an element has a particular CSS class.

Well, all modern browsers now allow you to do away with jQuery for duplicating the above functions. The classList API is pretty self explanatory. See the below:

el.classList.add("myclass") //adds a class to element
Syndicate content