Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.



Get Started Now!

How to Use change CSS styles in jQuery?

jQuery

So in this blog, we’re going to learn that How to Use change CSS styles in jQuery?

So let’s go ahead and do that for first in index.html, with help of style.css & main.js and define-

To retrieve or set the value of a CSS property, you can use css(). This works similar to attr() and prop(): pass one argument to read or two arguments to set a new value. For instance, you can achieve the same as with hide() like this:

 $(“p:first”).css(“display”, “none”);

You can change any CSS property in this simple way.

  redBox.css(“background-color”, “#AA5500”);

  $(“p”).css(“font-size”, “20px”);

You can even change the value of a property relative to its previous value

redBox.css(“width”, “+=20px”);
redBox.css(“height”, “-=20px”);

Also, you can retrieve multiple values by passing an array as the argument

 var properties = $(“p”).css([“font-size”, “line-height”, “color”]);

You can see that in the Developer Tools (F12 in browser) in the Inspector tab.

redBox.css(“user-select”, function() {
// [some logic here…]
return “none”;
});

Use change CSS styles in jQuery
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x