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 use jQuery style to manipulate css

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Editor to share with you how to use jQuery style to operate css, I hope you will learn something after reading this article, let's discuss it together!

JQuery style operation

Manipulate the css method:

JQuery can use the css method to manipulate and modify simple element styles, and some can manipulate classes to modify multiple styles.

1. Parameter only writes the property name, the property value is returned.

$(this) .css ("color")

two。 Parameters are property names, attribute values, comma-separated, set a set of styles, attributes must be in quotation marks, and values can be followed by units and quotation marks if they are numbers.

(this) .css ("color", "red")

(this) .css ("width", "220px")

3. Parameters can be in the form of objects, it is convenient to set multiple groups of styles, attribute names and attribute values are separated by colons, and attributes can be unquoted.

(this) .css ({"color": "blue", "font-size": "20px"})

Div {width:200px; height: 300px; background-color: pink } laugh and forget console.log ($("div"). Css ("width")); / / 200px $("div"). Css ("width", "350px"); $("div"). Css ("width", 300) ("div") .css ({"color": "blue", "font-size": 20, backgroundColor: "red"}) / / if it is a compound attribute, use the hump naming method, if the value is not a number, then add quotation marks to finish reading this article, I believe you have a certain understanding of "how to use jQuery style to operate css". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!

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