JQuery CSS of method examples


The CSS () method sets or returns one or more style attributes of the selected element.

Set CSS properties

To set the specified CSS properties, use the following syntax:


css("propertyname","value");

The following example sets background-color values for all matched elements: The instance


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

Set multiple CSS properties

To set multiple CSS properties, use the following syntax:


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

The following example sets background-color and font-size for all matched elements: The instance


$("p").css({"background-color":"yellow","font-size":"200%"});