JQuery  css() Method

please click here for more wordpress cource

The jQuery css() method is used to get or set the CSS properties of an HTML element. It is one of the most commonly used jQuery methods for manipulating styles of web pages.

Syntax for getting CSS property value using css() method:

$(selector).css(property)

where selector specifies the HTML element to be selected and property is the name of the CSS property to retrieve.

Syntax for setting CSS property value using css() method:

$(selector).css(property, value)

where selector specifies the HTML element to be selected, property is the name of the CSS property to set, and value is the new value for the CSS property.

Example of getting the CSS property value using css() method:

var color = $('p').css('color');

In this example, the color value of the selected p element will be stored in the color variable.

Example of setting the CSS property value using css() method:

$('p').css('color', 'blue');

In this example, the color of the selected p element will be set to blue.

You may also like...

Popular Posts

Leave a Reply

Your email address will not be published. Required fields are marked *