Javascript advanced programming --- classList attribute, classlist
1. Traditional methods:
You must use the className attribute to add, delete, and replace Class names. For example:
<div class="bd user disabled">...</div>
There are three class names in this div. To delete one class name from the class name, you need to split the three classes and then process them separately. The process is as follows:
<Script type = "text/javascript"> var className = div. className. split (/\ s +/); // find the class name var pos =-1, I, len; for (var I = 0; I <className. length; I ++) {if (className [I] = "user") {pos = I; break ;}; className. splice (I, 1); div. className = className. join (""); // re-assemble the remaining class names </script>
The above is a traditional method.
2. The new method classList () in html5 can completely get rid of the className attribute.
The specific use cases are as follows:
<!DOCTYPE html>
Note: currently, the classList attribute is only supported by FireFox3.6 + and Chrome.
Javascript Advanced Programming
PDF scanning software can be used to convert the image into text. The disadvantage is that the recognition accuracy is low.
How can we design javascript advanced programs?
The version number should be different. You should select the latest version, which is the second version-Translated by Cao Li songfeng.