Home  >  Article  >  Web Front-end  >  jQuery - Detailed explanation of css() method example_jquery

jQuery - Detailed explanation of css() method example_jquery

WBOY
WBOYOriginal
2016-05-16 17:03:27811browse

The css() method sets or returns one or more style properties of the selected element.

Set CSS properties

To set specific CSS properties, please use the following syntax:

Copy code The code is as follows:

css("propertyname","value");

The following example will set the background-color value for all matching elements:
Example
Copy code The code is as follows:

$("p").css ("background-color","yellow");

Set multiple CSS properties

To set multiple CSS properties, please use the following syntax:
Copy code The code is as follows:

css({"propertyname":"value","propertyname":"value ",...});

The following example will set the background-color and font-size for all matching elements:
Example
Copy code The code is as follows:

$("p").css({"background-color":"yellow","font-size ":"200%"});
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