Change click event handler in the code - Javascript jQuery

Javascript examples for jQuery:Mouse Event

Description

Change click event handler in the code

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> 
 </head> //from   w  w w.  ja v a2  s. com
 <body> 
  <div class="my"> 
   <a href="#" onclick="show()">me 1</a> 
   <a href="#" onclick="show()">me 2</a> 
  </div> 
  <script type="text/javascript">
$('.my').find('[onclick="show()"]').attr('onclick', 'showme()');

function show() {
   console.log('show');
}
function showme() {
   console.log('showme');
}

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

Related Tutorials