Tutorials Point


  jQuery Tutorial
  jQuery UI
  jQuery References
  jQuery Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

jQuery - removeClass( class ) Method


previous next AddThis Social Bookmark Button


Advertisements

Description:

The removeClass( class ) method removes all or the specified class(es) from the set of matched elements.

Syntax:

Here is the simple syntax to use this method:

selector.removeClass( class )

Parameters:

Here is the description of all the parameters used by this method:

  • class: The name of CSS class.

Example:

Following example would remove class red from the first para:

<html>
<head>
<title>The Selecter Example</title>
<script type="text/javascript" src="/jquery/jquery-1.3.2.min.js">
</script>
   
<script type="text/javascript" language="javascript">

   $(document).ready(function() {

     $("p#pid1").removeClass("red");
     $("p#pid2").removeClass("red");

   });

</script>
<style>
  .red { color:red; }
  .green { color:green; }
</style>

</head>
<body>

<p class="red" id="pid1">This is first paragraph.</p>
<p class="green" id="pid2">This is second paragraph.</p>

</body>
</html>

This would generate following result:

<html>
<head>
<title>The Selecter Example</title>
<script type="text/javascript" src="/jquery/jquery-1.3.2.min.js">
</script>
   
<script type="text/javascript" language="javascript">

   $(document).ready(function() {

     $("p#pid1").removeClass("red");
     $("p#pid2").removeClass("red");

   });

</script>
<style>
  .red { color:red; }
  .green { color:green; }
</style>

</head>
<body>

<p id="pid1">This is first paragraph.</p>
<p class="green" id="pid2">This is second paragraph.</p>

</body>
</html>

To understand it in better way you can Try it yourself.



previous next Printer Friendly

Advertisements


  

Advertisements