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.
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.
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>