Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to delete styles by jquery

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report