How to apply multiple CSS properties using a single jQuery method?
11
I want to apply multiple CSS properties and values to an element using a single jQuery method call.
I tried this syntax but it doesn't work:
$('.myclass').css('background-color': 'red', 'color': 'white');
What's the correct syntax for applying multiple CSS properties at once with jQuery?
1 Answer
0
To use multiple CSS properties and values using a single JQuery method use following code:
$('.myclass').css({'background-color': 'red','color':'white'});