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

Popular posts from this blog

gcc - MinGW's ld cannot perform PE operations on non PE output file -

How to connect android app to App engine -

hadoop - Running Map Reduce Job shows error - Mkdirs failed to create /var/folders/ -