How to use multiple CSS properties and values using a single JQuery method?

#18
119
1 Answer
Question Image

I want to apply multiple CSS properties and values using a single JQuery method,

like this :

selector.CSS('property1': 'value1', 'property2': 'value2');

This method is not working, tell me how it is possible?

My Code is:

$('.myclass').css('background-color': 'red', 'color': 'white');


Related to:
jquerycsspropertyvalue
0
Answer
Answer 1 of 1
# 11

To use multiple CSS properties and values using a single JQuery method use following code:

$('.myclass').css({'background-color': 'red','color':'white'});

0
0
0
Related Articles

If you still have a question about this, submit it in our Q&A community - Ask Question