- 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 apply CSS properties using jQuery?
To apply CSS properties using jQuery, use the css() method. It’s easy to apply any CSS property using jQuery method css( PropertyName, PropertyValue ).
Here is the syntax for the method −
selector.css( PropertyName, PropertyValue );
Example
Here you can pass PropertyName as a JavaScript string and based on its value, PropertyValue could be string or integer.
<html> <head> <title>jQuery css() method</title> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function() { $("li").eq(4).css("color", "green"); }); </script> </head> <body> <div> <ol> <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> </ol> </div> </body> </html>
- Related Articles
- How to apply multiple CSS properties using jQuery?
- How to apply CSS style using jQuery?
- How to change CSS using jQuery?
- How to Apply Shadow Effect on Text Using CSS?
- How to apply inline CSS?
- How to Play and Pause CSS Animations using CSS Custom Properties?
- How to remove all CSS classes using jQuery?
- How to remove all CSS classes using jQuery?
- How to apply CSS to iframe?
- How jQuery selects elements using CSS?
- How to iterate a JavaScript object's properties using jQuery?
- How to set background image in CSS using jQuery?
- How to inherit CSS properties of parent Element using JavaScript?
- How to Justify Text using text-align & text-justify CSS Properties?
- How to manipulate CSS pseudo-elements ::before and ::after using jQuery?

Advertisements