1. Why the variable name of JavaScript does not use the naming method in CSS, and the choice of using the Hump naming method
Because "-" in JavaScript means subtraction, an unnecessary problem arises if you use "-".
2. There is already a ClassName method in JavaScript to add the class name, why do you want to add a new Classlist.add method
Because Classlist provides the ability to judge DOM element types, string processing, regular expression matching and classname functionality is not perfect.
P.classlist.length; Gets the number of class names in the P element
P.classlist.item (1); Gets the class name of index 1 in the P element
P.classlist.add ("big"); Add the big class to the P element
P.classlist.remove ("big"); To remove the big class from the P element
P.classlist.contains ("big"); Determine if the P element contains a class called Big
P.classlist.toggle ("big"); If the big class exists in the P element, it is deleted, and if the big class does not exist in the P element, the big class is added to P
Disadvantages of Classlist
Only a single class name can be manipulated, and if the class name argument in the Add,remove,contains,toggle method contains a space, the method call will error
3. In JS, you can customize the Add attribute why do you have to have data to add custom properties, what is the difference between them.
Easy to manage
Thinking of adding JS API to HTML5