- 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 change CSS using jQuery?
To change CSS using jQuery, use the jQuery css() method.
Example
You can try to run the following code to change CSS using 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(){ $("h2").css("backgroundColor", "red"); $("#myid").css({ "backgroundColor": "gray", "color": "white"}); $(".myclass").css("border", "2px solid black"); }); </script> </head> <body> <h2>Heading 2</h2> <p id="myid">This is some text.</p> <div class="myclass">This is some text.</div> </body> </html>
- Related Articles
- How to apply CSS properties using jQuery?
- How to apply CSS style using jQuery?
- How to change the background color using jQuery?
- How to change the background image using jQuery?
- How to change the element id using jQuery?
- How to apply multiple CSS properties using jQuery?
- How to remove all CSS classes using jQuery?
- How to remove all CSS classes using jQuery?
- How jQuery selects elements using CSS?
- How to change text inside an element using jQuery?
- How to set background image in CSS using jQuery?
- How to change the font size using CSS?
- How to change the value of an attribute using jQuery?
- How to change the href attribute for a hyperlink using jQuery?
- How to manipulate CSS pseudo-elements ::before and ::after using jQuery?

Advertisements