Get button id via .on "click" event - Javascript jQuery

Javascript examples for jQuery:Form Button

Description

Get button id via .on "click" event

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://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//from ww  w  . j a  v  a 2  s.co  m
$(document).on('click', ".delete", function(){
    console.log('you clicked '+ this.id);
});
    });

      </script> 
 </head> 
 <body> 
  <div class="delete" id="one">
    one 
  </div> 
  <div class="delete" id="two">
    two 
  </div>  
 </body>
</html>

Related Tutorials