Change the page element style using JavaScript can also be achieved, but there is no more concise way, the answer is yes, now have jquery, it seems that the JS code to thin a lot of, fulfilled the sentence: "jquery to make JavaScript code concise!" "And come to the point of jquery how to add and remove CSS classes:
1. Removeclass ()-Remove CSS Class
$ ("#target"). Removeclass ("Oldclass");
#target refers to the ID of the element that needs to be removed from the CSS class//oldclass refers to the name of the
CSS class
2.addClass ()-Add CSS Class
$ ("#target"). AddClass ("Newclass");
#target refers to the ID of the element that needs to add a style//newclass refers to the name of the
CSS class
3. Toggleclass ()-Add or remove a CSS class: if the CSS class already exists, it will be removed, and conversely, if the CSS class does not exist, it will be added.
$ ("#target"). Toggleclass ("Newclass")
//If the element with ID "target" already has a CSS style defined, it will be removed;
//Otherwise, the CSS class "Newclass" will be assigned to the ID
4.hasClass ("ClassName")-determine if CSS already exists
In practice, we usually define these CSS classes first, and then change the page element style by using JavaScript event triggers (such as clicking a button). In addition, jquery provides a method Hasclass ("ClassName") to determine whether an element has been assigned to a CSS class. By the way, tell the novice, jquery is worth having, free to study.