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