Add and remove style class : removeClass « jQuery « JavaScript Tutorial






<html>
  <head>
    <script type="text/javascript" src="js/jquery-1.3.2.js"></script>
    <style type="text/css">
        .changeP { font-weight: bold; color:red;}
    </style>

    <script type="text/javascript">
 $(document).ready(function(){
    $("input.buttonA").click(function(){ $("p.fifthparagraph").addClass("changeP"); });
    $("input.buttonB").click(function(){ $("p.fifthparagraph").removeClass("changeP"); });

 });

    </script>
  </head>
  <body>
    <input type="button" value="Change" class="buttonA" />
    <input type="button" value="Change" class="buttonB" />


    <div style="background:#eee;" class="contentToChange">
        <h2>Header 2</h2>
       
        <p class="firstparagraph">Lorem ipsum <em>dolor</em> sit amet, consectetuer <em>adipiscing</em> elit, sed diam nonummy nibh euismod <em>tincidunt</em> ut laoreet dolore magna aliquam erat <strong>volutpat</strong>. Ut wisi enim ad minim <em>veniam</em>, quis nostrud exerci <strong>tation</strong> ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
        
        <p class="fifthparagraph">Lorem ipsum <em>dolor</em> sit amet, consectetuer <em>adipiscing</em> elit, sed diam nonummy nibh euismod <em>tincidunt</em> ut laoreet dolore magna aliquam erat <strong>volutpat</strong>. Ut wisi enim ad minim <em>veniam</em>, quis nostrud exerci <strong>tation</strong> ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
        
    </div>

  </body>
</html>








30.87.removeClass
30.87.1.Add and remove style class
30.87.2.Remove style class from first paragraph
30.87.3.Remove class from even number paragraph
30.87.4.Remove class from all
30.87.5.removeClass(class) removes all or the specified class