An example of setting CSS properties in jQuery

  • 2020-03-30 01:24:43
  • OfStack

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

Related articles: