In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to use .css (propertyName)". In daily operation, I believe many people have doubts about how to use .css (propertyName). The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about how to use .css (propertyName). Next, please follow the editor to study!
Description: gets the value of the style attribute of the first element in the matching element collection
Added version: 1.0.css (propertyName)
PropertyName
Type: String
A css property name.
Added version: 1.9.css (propertyNames)
PropertyNames
Type: Array
An array of one or more CSS attributes
The .css () method can easily get the style attribute value of the first element in the matching element collection. For some attributes, browsers access style attributes in different ways. This method is very convenient for obtaining these attributes (for example, some attributes are obtained through the getComputedStyle () method in standard browsers, but through currentStyle and runtimeStyle attributes in Internet Explorer) and Some specific properties are written differently in different browsers. For example, Internet Explorer's DOM writes the float attribute as a styleFloat implementation, and the W3C standard browser writes the float attribute as cssFloat. To maintain consistency, you can simply use "float", and jQuery will return the correct value it needs for each browser.
In addition, jQuery can also parse different ways to write the DOM attribute of CSS and multiple-word formatted (words connected with horizontal bars, such as background-color). For example: jQery parses .css ('background-color') and .css (' backgroundColor') and returns the correct value. Different browsers may return CSS color values that are logically the same, but behave differently in text, such as # FFF, # ffffff, and rgb (255255255).
Shorthand CSS attributes (such as margin, background, border) are not supported. For example, if you want to retrieve margin, you can use $(elem) .css ('marginTop') and $(elem) .css (' marginRight'), as well as others.
Starting with jQuery 1.9, pass an array of style attributes of CSS to .css () objects that will return property-value pairing. For example, to get the four margin width values border-width of an element, you can use $(elem) .css (["borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth"]).
Example:
Example: click div to get its background color
Div {width:60px; height:60px; margin:5px; float:left;}
$("div") .click (function () {
Var color = $(this) .css ("background-color")
("# result") .html ("That div is" + color + ".")
})
At this point, the study on "how to use .css (propertyName)" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.