how to get id of any control using javascript? -
i have html page various textbox , button
then added javascript
window.onload = function () { window.addeventlistener('click', function (evt) { alert(this.id); }, false); };
my goal return id of control clicked user (as alert)? add more this. alert ok now. thank you
use target
of event. here's runnable sample:
window.onload = function () { window.addeventlistener('click', function (evt) { alert(evt.target.id); }, false); };
<input id="button" type="button" value="button" /> <input id="text" type="text" />
Comments
Post a Comment