Skip to content

Manipulate a DOM’s CSS using jQuery

You can get and set the value of pretty much any CSS attribute of a HTML element using jQuery’s .css() function.

Retrieve the value of a CSS attribute:

<p id="demo" style="color:red">Demo</p>
$("#demo").css("color");

Set the value of a CSS attribute:

<p id="demo">Demo</p>
$("#demo").css("color", "red");

Be First to Comment

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.