Click to add CSS class - Javascript jQuery

Javascript examples for jQuery:Mouse Event

Description

Click to add CSS class

Demo Code

ResultView the demo in separate window


<html>
   <head> 
      <style>

.open {//w  w  w  .  j  a  v a2s .  co m
   color: blue;
}


      </style> 
   </head> 
   <body> 
      <div id="dropdown-nav">
         Drop-down nav
      </div> 
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> 
      <script>
$("#dropdown-nav").click(function() {
    $(this).addClass("open");
});

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

Related Tutorials