In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
In this article, the editor introduces in detail "how to delete a class in jquery". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to delete a class in jquery" can help you solve your doubts.
Method: 1, with removeClass (), you can remove the specified class from the element, syntax "specify the element .removeClass (" class name ")", if you omit the parameter, you can delete all classes; 2, with toggleClass (), the syntax "specify the element .toggleClass (" class name ", false)".
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
The method to delete a class in jquery
Method 1: use removeClass ()
The removeClass () method removes one or more classes from the selected element.
$(selector) .removeClass ("class name")
If no parameters are specified, the method removes all classes from the selected element.
Example: remove the "intro" class of the p element:
$(document) .ready (function () {$("button") .click (function () {$("p"). RemoveClass ("intro");}) .intro {font-size: 120%; color: red;} this is a title and this is a paragraph.
This is another paragraph.
Remove the "intro" class of all P elements
Method 2: use toggleClass ()
The toggleClass () method toggles one or more classes that add and remove selected elements.
This method checks the class specified in each element. Add a class if it does not exist and delete it if it is set. This is called switching effect.
However, by using the "switch" parameter, you can specify that only classes are deleted or added.
The $(selector) .toggleClass (classname,switch) parameter is required to describe classname. Specifies one or more class names to be added or removed. If you need to specify several classes, separate the class names with spaces. Function (index,currentclass) is optional. A function that returns one or more class names that need to be added / deleted.
Index-returns the index position of the elements in the collection.
Currentclass-returns the current class name of the selected element.
Switch is optional. A Boolean value that specifies whether only classes are added (true) or removed (false).
Example:
$(document) .ready (function () {$("button") .click (function () {$("p"). ToggleClass ("intro", false);}) .intro {font-size: 120%; color: red;} this is a title and this is a paragraph.
This is another paragraph.
Remove the "intro" class of all P elements
After reading this, the article "how to delete a class in jquery" has been introduced. If you want to master the knowledge of this article, you still need to practice and use it yourself. If you want to know more about related articles, please follow the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.