How to apply multiple CSS properties using jQuery?

jQueryWeb DevelopmentFront End Technology

Apply multiple CSS properties using a single JQuery method CSS( {key1:val1, key2:val2....). You can apply as many properties as you like in a single call.

Here is the syntax for the method −

selector.css( {key1:val1, key2:val2....keyN:valN})

Here you can pass key as property and val as its value as described above.


You can try to run the following code to learn how to apply multiple CSS properties using jQuery:

Live Demo

      <title>jQuery CSS</title>
      <script src = ""></script>
         $(document).ready(function() {
            $("li").eq(2).css({"color":"red", "background-color":"green"});
            <li>list item 1</li>
            <li>list item 2</li>
            <li>list item 3</li>
            <li>list item 4</li>
            <li>list item 5</li>
            <li>list item 6</li>
Published on 17-Dec-2017 08:11:05