Earlier we have been exposed to the hassclass,addclass,removeclass of jquery and other operations on the class but sometimes we need to apply to the original things, at this time classlist will be a great glory;
Personal understanding: Classlist is like a collection of class names, class +list represents the list of classes, and since it is the use of classes, we will introduce the members of the Classlist:
Length
static properties. Gets the number of element class names: Var Number=document.body.classlist.length;
Item
Gets the class name of the element, accepting a parameter, the numeric index value: var name=docuemnt.body.classlist.item (index);
Add
class for adding elements, accepting a parameter (class name) Note: You can only add one class name at a time: Document.body.classList.add ("classname");
Remove
Delete the element class, accept an argument (only one at a time): Document.body.classList.remove (' classname ');
Contains
Detects whether a class is included and returns a Boolean value. Document.body.classList.contains (' classname ');//true or False
Toggle
The equivalent of add remove contains, the existence of the class on the Remove (), does not exist to delete the Add ();d ocumen.body.classList.toggle (' classname ');
Talking about Classlist