- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 define multiple CSS attributes in jQuery?
To define multiple CSS attributes in jQuery, use the css selector or the addClass() method. Let’s see how to do it using css selector.
Pair up strings representing property names with the corresponding values.
Example
You can try to run the following code to learn how to define multiple CSS attributes in jQuery:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("#demo").css({ "background-color": "#F1F1F1", "font-style" : "italic" }); }); </script> </head> <body> <h1 id="demo">Countries</h1> </body> </html>
- Related Articles
- How to apply multiple CSS properties using jQuery?
- How to define multiple style rules for a single element in CSS?
- How to define attributes of a class in Python?
- How to add attributes to an HTML element in jQuery?
- How to remove all style attributes using jQuery?
- How to filter object array based on attributes in jQuery?
- How to add and remove HTML attributes with jQuery?
- What are event attributes in jQuery?
- What are the methods in jQuery to manipulate attributes?
- How to use jQuery selectors on custom data attributes using HTML5?
- How to select multiple elements with jQuery?
- Using Data-Attributes (data-*) in CSS
- How to wrap multiple divs in one with jQuery?
- How to Add and Remove multiple classes in jQuery?
- How to change CSS using jQuery?

Advertisements