Home  >  Article  >  Web Front-end  >  How to add css in jquery

How to add css in jquery

青灯夜游
青灯夜游Original
2021-05-13 15:29:013063browse

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

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!

Statement:
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
Previous article:What is reset cssNext article:What is reset css