Javascript examples for jQuery:Form Button
Store the value of a button on click event in jQuery
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-2.0.2.js"></script> <script type="text/javascript"> $(function(){// w w w .jav a2 s . com $('button').on('click', function() { var colour = $.trim( $(this).html() ); console.log("You have chosen " + colour); }); }); </script> </head> <body> <button> red </button> <button> blue </button> <button> yellow </button> </body> </html>