custom ToggleClass() in jquery - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:toggleClass

Description

custom ToggleClass() in jquery

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> 
  <style id="compiled-css" type="text/css">

.bold { font-weight:700; }


      </style> 
 </head> /*from w ww  . j  a  v  a  2 s  .  c o  m*/
 <body> 
  <a href="#" class="js-toggleClass">Toggle class</a> 
  <script type="text/javascript">
$('.js-toggleClass').click(function(e) {
    e.preventDefault();
    $(this).toggleClass('bold');
});

      </script>  
 </body>
</html>

Related Tutorials