Get value of a button type button with jQuery - Javascript jQuery

Javascript examples for jQuery:Form Button

Description

Get value of a button type button with jQuery

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.5.2.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/* w w w.  j a  v  a  2 s .c o m*/
$('button').click(function() {
            console.log($(this).text());
        });
    });

      </script> 
 </head> 
 <body> 
  <button type="button" class="green test">Button 1</button> 
  <button type="button" class="green active test">Button 2</button>  
 </body>
</html>

Related Tutorials