I'm trying to set the CSS of an element on the fly. Can I use a CSS class inside the brackets of JQuery's css()?
I've looked in http://api.jquery.com/css/ but can't find anything on it.
To be clear, rather than doing the following, with multiple CSS items:
$("div").css("background-color":"yellow", "color":"blue");
I'd like to be able to do something along the lines of the following:
$("div").css('.abc');
(where 'abc' is the class in a stylesheet that contains multiple CSS lines)
I don't think you can. But you can use :
$("div").addClass("abc");
.addClass()
And here's all the class attributes that you can use in jquery : here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With