The best jQuery css () method Tutorial In 2024, In this tutorial you can learn jQuery css () method,Returns CSS property,Examples,Set CSS properties,Examples,Set multiple CSS properties,Examples,

jQuery css () method

jQuery css () method

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


Returns CSS property

To return the value of the specified CSS property, use the following syntax:

css("propertyname");

The following example will return the first matching element of the background-color value:

Examples

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



Set CSS properties

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

css("propertyname","value");

The following example will match all the elements set background-color value:

Examples

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



Set multiple CSS properties

To set multiple CSS attributes, use the following syntax:

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

The following example will match all the elements set background-color and font-size:

Examples

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

jQuery css () method
10/30