Jquery css

jQuery – css() Method

The jQuery CSS methods include:

  1. .css() – Allows you to get or set one or more CSS properties for the selected elements. You can pass a single property and value, or an object containing multiple properties and values.
  2. .addClass() – Adds one or more classes to the selected elements.
  3. .removeClass() – Removes one or more classes from the selected elements.
  4. .toggleClass() – Toggles one or more classes on or off for the selected elements.

These methods can be used to modify various aspects of an element’s appearance, such as its color, size, position, font, and more.

Here’s an example of using the .css() method to modify an element’s background color:


<!DOCTYPE html>
    <title>jQuery CSS Example</title>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
        #box {
            width: 200px;
            height: 150px;
            background-color: yellow;
    <div id="box">This is a box</div>
        $(document).ready(function() {
            // Change the background color of the box to red
            $("#box").css("background-color", "red");
Scroll to Top