Javascript examples for DOM HTML Element:Input Button
Handle button click event and display value attribute
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/* w w w . j a v a 2 s.co m*/ var buttons = document.getElementsByTagName('button'); for (i = 0; i < buttons.length; i++) { buttons[i].addEventListener('click', function () { console.log(this.value); }, false) } } </script> </head> <body> <button value="yes">Yes</button> <button value="no">No</button> </body> </html>