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--
This article mainly explains "jquery how to add classes", the content of the explanation is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "jquery how to add classes"!
Two methods: 1, with attr (), just add a value to the class attribute, syntax "element object .attr (" class "," class name ");". 2, with addClass (), add one or more classes to the syntax "element object .addClass (" class name ")". If you add more classes, separate the class names with spaces.
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
Two methods of adding classes to jquery
1. Use attr ()
Attr () can set the attribute value of the selected element and add a class when the attribute is "class".
This method is used to add a class when there is no class before.
Example: add a class to the first p element
$(document) .ready (function () {$("button") .click (function () {$("p:first"). Attr ("class", "intro");}) .intro {font-size: 120%; color: red;} This is a heading
This is a paragraph.
This is another paragraph.
Add a class to the first p element
2. Use addClass ()
The addClass () method adds one or more classes to the selected element.
This method does not remove the existing class attribute, but simply adds one or more class attributes. To add more than one class, separate the class names with spaces.
Example: add a class to the second p element
$(document) .ready (function () {$("button") .click (function () {$("p:nth-child (3)") .addClass ("intro");}) .intro {font-size: 120%; color: red;} a subtitle
The first paragraph
The second paragraph
The third paragraph
Add a class to the second p element
Thank you for your reading, the above is the content of "how to increase the class of jquery". After the study of this article, I believe you have a deeper understanding of how to increase the class 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.
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.