Hey everyone,
I am looping through all the inputs on a page, then trying to get the name attribute of the element that's clicked.
When I click on any of the inputs I get a "Uncaught TypeError: Cannot read property 'name' of undefined". What am I doing wrong?Code:var allInputs = document.getElementsByTagName('input'); for (var i = 0; i < allInputs.length; i++) { if (allInputs[i].className == 'someclass') { allInputs[i].onmousedown = function () { alert(allInputs[i].name); } } }
Thanks


Reply With Quote
Bookmarks