The Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <!DOCTYPE html>
<html>
<body>
<button id="1" onClick="reply_click(this.id)">B1</button>
<button id="2" onClick="reply_click(this.id)">B2</button>
<button id="3" onClick="reply_click(this.id)">B3</button>
<script type="text/javascript">
function reply_click(clicked_id)
{
alert(clicked_id);
}
</script>
</body>
</html>
|
The Result
Reference:
JavaScript - onClick to get the ID of the clicked button
https://stackoverflow.com/questions/4825295/javascript-onclick-to-get-the-id-of-the-clicked-button

No comments:
Post a Comment