0
JS classlist vs classname
I don't get the difference between using classname vs classlist??? Both can display all the class(s) within an element. But classlist allows you to target individual class within the element. It just seems like classlist is a much better option compared to classname...?? And like changing an element via classname will change ALL the classes inside an element??
1 Respuesta
+ 2
className and classList. InJavaScript, there are two main ways to add and remove classes dynamically to a DOM element. The one is via the property className which returns a string and the other via the propertyclassList, which returns a DOMTokenList object with some useful methods.