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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -