How to delete styles by jquery
This article mainly explains "how to delete styles in jquery". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's ideas to study and learn how to delete styles in jquery.
Delete method: 1, use removeAttr () method, syntax "$(element). RemoveAttr (" attribute name ")", attribute name can be id, class or style;2, with removeClass () method, syntax "$(element) .removeClass (" class name ")".
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
The method of deleting styles by jquery
Method 1: using removeAttr () method
The removeAttr () method removes attributes from the selected element.
$(document) .ready (function () {$("button") .click (function () {$("H2") .removeAttr ("id"); $("p") .removeAttr ("style")) $("p") .removeAttr ("class");});}); # H2 {color: red } .box {color: # FFC0CB;} this is a title and this is a paragraph.
This is another paragraph.
Delete Styl
Effect picture:
Method 2: using removeClass () method
The removeClass () method removes one or more classes from the selected element.
Note: if no parameters are specified, the method removes all classes from the selected element.
$(document) .ready (function () {$("button") .click (function () {$("p") .removeClass (); $("div") .removeClass ("intro");}) ); .box1 {color: # FFC0CB;} .box2 {color: # FFC0CB } .box3 {color: # FFC0CB;} .intro {font-size: 120%; color: red This is a paragraph.
This is a paragraph.
This is a paragraph.
This is another paragraph.
Delete Styl
Thank you for your reading, the above is the content of "jquery how to delete the style", after the study of this article, I believe you have a deeper understanding of how to delete the style of jquery, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!