Home > Article > Web Front-end > How to add css in jquery
In jquery, you can use the css() method to add css styles, which can set one or more css styles for matching elements; the syntax format is "$(selector).css(attribute name, Attribute value)" or "$(selector).css({attribute name: attribute value, attribute name: attribute value...})".
The operating environment of this tutorial: windows7 system, jquery1.10.0 version, Dell G3 computer.
In jquery, you can use the css() method to add css styles.
css() method returns or sets one or more style properties of the matched element.
Method 1:
$("p").css({ color: "#ff0011", background: "blue" });
Method 2: Key-value pair
$("p").css("color","red");
Recommended related video tutorials: jQuery Tutorial (Video)
The above is the detailed content of How to add css in jquery. For more information, please follow other related articles on the PHP Chinese website!