What are the function methods of JavaScript
This article mainly talks about "what are the functional methods of JavaScript". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what are the function methods of JavaScript"?
Method: 1, use attr () to set the value of class attribute to empty, syntax "$(selector) .attr (" class ",") "; 2, use removeAttr () to remove class attribute, syntax" $(selector) .removeAttr ("class") ".
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
There are two ways for jquery to remove the class attribute:
Use attr () to set the value of the class attribute in the element to null
Syntax: $(selector) .attr ("class", "")
Use removeAttr () to remove the class attribute from an element
Syntax: $(selector) .removeAttr ("class")
Example:
$(document) .ready (function () {$("button") .click (function () {$(".box1") .attr ("class", "); $(" .box2 ") .removeAttr (" class ") });}); div {border: 1px solid red; margin: 10px } .box1 {background-color: # FFC0CB;} .box2 {background-color: green; color: white } Test text
Remove the class attribute
At this point, I believe you have a deeper understanding of "what are the functional methods of JavaScript?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!