Prevent activation on first click - Javascript jQuery

Javascript examples for jQuery:Mouse Event

Description

Prevent activation on first click

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-2.1.3.js"></script> 
  <script type="text/javascript">
    $(function(){//  ww w.  jav  a 2  s .  c  o  m
    $('.special').on('click', function(e) {
        if( !$(this).is('.clicked') ) {
            e.preventDefault();
            $(this).addClass('clicked');
        }
    });
    });

      </script> 
 </head> 
 <body> 
  <a class="special" href="https://www.google.com/" target="_blank">Google.com</a>  
 </body>
</html>

Related Tutorials