WebMasterCampus
WEB DEVELOPER Resources

jQuery Remove CSS Style Added With CSS Function

Learn how to use jQuery to Remove CSS Style Added With CSS Function


jQuery Remove CSS Style Added With CSS Function

jQuery provides a css method to remove css style using jQuery that either set by jQuery or normal CSS style.

The css() method sets or returns one or more style properties for the selected elements.

Set Single CSS Syntax

css("propertyname","value");

Set Multiple CSS Syntax

css({"propertyname": "value", "propertyname": "value"});

jQuery to Remove CSS Style Example

Let’s change the color of a div using jQuery CSS method. When user will click on button (Remove COlor), it will remove the color using same CSS method by assigning empty or transparent value.

  <script src="https://code.jquery.com/jquery-git.js"></script>
   <script>

    $(document).ready( function(){

      $("#colorBox").css("background-color", "pink");

      $("#btnColorRemove").click(function() {

        $("#colorBox").css("background-color", "");

      });

    });

  </script>

  <div id="colorBox" style="border:1px solid gray; width:100px; height:100px;"></div> 
  <button id="btnColorRemove">Remove Color</button>
Created with love and passion.