Check what button was clicked - Javascript jQuery

Javascript examples for jQuery:Form Button

Description

Check what button was clicked

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> 
      <script>
$(document).ready(function(){
    $(".p").click(function(e){
        console.log($(e.currentTarget).attr("value"));//button text on which you clicked
    });/* w  ww .  j ava  2 s  .co m*/
});

      </script> 
   </head> 
   <body> 
      <input type="button" class="p" value="test">  
   </body>
</html>

Related Tutorials