In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "whether jquery can add css style", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "whether jquery can add css style" bar!
Jquery can add css style, method: 1, use css () to set the style attribute of the matching element, syntax "$(selector) .css (attribute name, attribute value)"; 2, use attr (), syntax "$(selector) .attr (" style "," style code ")".
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
Jquery can be styled with css, such as using the css () method to add CSS styling.
The method of adding css style to jquery
1. Use css ()
The css () method returns or sets one or more style properties of the matching element.
Set the syntax for css style
The $(selector) .css (name,value) parameter is required to describe name. Specifies the name of the CSS attribute. This parameter can contain any CSS attribute, such as "color". Value
Optional. Specifies the value of the CSS property. This parameter can contain any CSS attribute value, such as "red".
If an empty string value is set, the specified attribute is removed from the element.
Example:
$(document) .ready (function () {$("button") .click (function () {$("p"). Css ("color", "red");})
This is a paragraph.
This is another paragraph.
Change the color of a paragraph
2. Use attr ()
The attr () method sets or returns the property value of the selected element.
When you use the attr () method to set the style attribute of an element, you can add a css style to the element.
$(document) .ready (function () {$("button") .click (function () {/ / $("div") .attr ({"style": "border: 5px solid paleturquoise;"}); $("div") .attr ("style", "border: 5px solid paleturquoise") Width: 200px; ");});}); hello
Add css styles to div elements
Thank you for your reading, the above is the content of "whether jquery can add css style", after the study of this article, I believe you can add css style to jquery this question has a deeper understanding, the specific use of the situation also 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.