jQuery

How To Change CSS Style With jQuery

In this tutorial, we are going to see how to change CSS style with jQuery. JQuery’s .css() method can be used with CSS properties. To modify a single CSS property, the method uses two arguments: the first is the name of the desired CSS property and the second is the new value.

.css("property", "value");

If the CSS property is not already used to the object, it will add the new property and set it to the given value. If the property already exists for the object, the existing value of the property will be updated with the new value.
 

Example :

The following example will set the value of the background-color property for ALL matching elements (paragraphs):

$("p").css("background-color", "red");
mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

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