What I want is to get the id (i.e myHeader, myHeader2, etc.)
This is what I’m trying now,
HTML:
<input type="text" id="myHeader" onblur="getValue(this)" />
<input type="text" id="myHeader2" onblur="getValue(this)" />
<input type="text" id="myHeader3" onblur="getValue(this)" />
<input type="text" id="myHeader4" onblur="getValue(this)" />
Javascript:
function getValue(obj){
var someVar = document.getElementById(obj).value;
}
But I’m not getting anything, the event is not firing as well, how do I do this?
Your
objobject already haveidandvalueproperty:Note that when you pass
thiscontext to your function, you pass your DOM element. Not id. And you can operate with it already as with DOM element. No need fordocument.getElementById.