Is there another way to get an DOM element's ID?
element.getAttribute('id')
Is there another way to get an DOM element's ID?
element.getAttribute('id')
In events handler you can get id as follows
function show(btn) {
console.log('Button id:',btn.id);
}
<button id="myButtonId" onclick="show(this)">Click me</button>