My code would pretty much speak for itself about what I'm about to achieve but just to clarify...
I want to return an the input value after long press (mousedown for 200ms).
It's working perfectly outside the for loop but inside the the loop it seems like not.
For this.value
it returned undefined and for gangina[i].value
it returned nothing.
Here is the jsFiddle:
http://jsfiddle.net/hezi_gangina/nxao19oc/
Here is my code :
<input type=button value=1>
<input type=button value=2>
<script>
var hezi;
var gangina=document.getElementsByTagName("input");
alert(gangina[1].value); //THIS IS OK! :)
for(i=0;i<gangina.length;i++)
{
gangina[i].onmousedown=function()
{
hezi=setTimeout
(
function()
{
alert('this = '+this.value); // = undefined
alert('gangina['+i+'] = '+gangina[i].value); // = nothing
},200
);
}
}
</script>
Small tweak needed here...