Home > Web Front-end > Front-end Q&A > How to add css in jquery

How to add css in jquery

青灯夜游
Release: 2023-01-06 11:13:00
Original
3105 people have browsed it

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...})".

How to add css in jquery

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" });
Copy after login

Method 2: Key-value pair

$("p").css("color","red");
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template