Bind function on different buttons - Javascript jQuery

Javascript examples for jQuery:Form Button

Description

Bind function on different buttons

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.8.3.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//w w  w.  ja v a  2 s.  c  om
 for(var i=1; i<=3; i++){
   $('#' + i).live('click', function(){
       console.log(this.id);
   });
};
    });

      </script> 
 </head> 
 <body> 
  <input id="1" type="button" value="one"> 
  <input id="2" type="button" value="two"> 
  <input id="3" type="button" value="three">  
 </body>
</html>

Related Tutorials