

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to apply multiple CSS properties using jQuery?
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.
Example
You can try to run the following code to learn how to apply multiple CSS properties using jQuery:
<html> <head> <title>jQuery CSS</title> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function() { $("li").eq(2).css({"color":"red", "background-color":"green"}); }); </script> </head> <body> <div> <ul> <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> </ul> </div> </body> </html>
- Related Questions & Answers
- How to apply CSS properties using jQuery?
- How to define multiple CSS attributes in jQuery?
- How to change CSS using jQuery?
- How jQuery selects elements using CSS?
- How to iterate a JavaScript object's properties using jQuery?
- How to compare multiple properties in MongoDB?
- How to remove all CSS classes using jQuery?
- How to remove all CSS classes using jQuery?
- How to inherit CSS properties of parent Element using JavaScript?
- How to include multiple js files using jQuery $.getScript() method?
- How to set background image in CSS using jQuery?
- CSS Border Properties
- CSS Background Properties
- CSS Dimension Properties
- CSS Margin Properties
Advertisements