how to get the id of an element in javascript on click code example
Example 1: get id of clicked element javascript
<button id="3" onClick="reply_click(this.id)">B3</button>
<script type="text/javascript">
function reply_click(clicked_id)
{
alert(clicked_id);
}
</script>
Example 2: get id of element javascript
var element = document.getElementsByTagName("div")[0];
var id = element.id;