Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use a CSS class inside the brackets of jquery's css()?

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)

like image 811
Steve Avatar asked Dec 01 '22 23:12

Steve


1 Answers

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

like image 140
Rafael Adel Avatar answered Dec 04 '22 07:12

Rafael Adel