IMG-LOGO
Home Course CSS Method in jQuery

CSS Method in jQuery

by MH RISHAD - 01 Jan 1970
IMG

CSS method sets or returns single and multiple style properties for the selected elements/contents.

CSS Property to return

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

css("propertyname");

The following example will return the color value of the first matched element:

Example

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

CSS Property to Set

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

css("propertyname","value");

The following example will set the color value for ALL matched elements:

Example

$("p").css("color", "red");

Set Multiple CSS Properties

To set multiple CSS properties, use the following syntax:

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

The following example will set a background-color and a font-size for ALL matched elements:

Example

$("p").css({"color": "red", "font-size": "18px"});
Tags:
Share:

Leave a Comment

Required fields are marked *