get the name of the id by clicking on a div

0

I was wondering how to make the name of a div id saved in a variable and then show the value of this variable with an alert, this dynamically, only with javascript.

    
asked by Jorge 02.12.2018 в 02:37
source

1 answer

0

If I understood correctly, what you want to do is this:

function showID(clicked_id)
{
    alert(clicked_id);
}
<button id="1" onClick="showID(this.id)">Boton 1</button>
<button id="2" onClick="showID(this.id)">Boton 2</button>
<button id="3" onClick="showID(this.id)">Boton 3</button>
    
answered by 02.12.2018 / 04:53
source