Javascript examples for DOM HTML Element:Input Button
Reporting Which Button Was Clicked when Clicked by display its id
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <script> function myFunction(e){//from ww w. ja va 2 s.co m console.log(e.id); } </script> <input type="button" id="1" class="buttonID" value="answer" onClick="myFunction(this)"> <input type="button" id="2" class="buttonID" value="answer" onClick="myFunction(this)"> <input type="button" id="3" class="buttonID" value="answer" onClick="myFunction(this)"> </body> </html>