Hello.
Some days ago I posted a message about this (somebody replied asking me
if I was using IE, but I am using Mozilla 1.7.5):
This 'for' statment works for me, i.e.:
for (var i = aElts.length; i--; ){
var oElement = aElts[i];
if (oElement.id)
if (oElement.id == 'alert2')
oElement.onclic k = Alert;
}
}
But why this doesn't work:
for (oElement in aElts){
var oElement = aElts[i];
if (oElement.id)
if (oElement.id == 'alert2')
oElement.onclic k = Alert;
}
}
Why?
I am attaching two testcases (testcase A works, testcase B doesn't work;
and the JS Console is not warning about anything).
Thanks in advance.
knocte
Some days ago I posted a message about this (somebody replied asking me
if I was using IE, but I am using Mozilla 1.7.5):
This 'for' statment works for me, i.e.:
for (var i = aElts.length; i--; ){
var oElement = aElts[i];
if (oElement.id)
if (oElement.id == 'alert2')
oElement.onclic k = Alert;
}
}
But why this doesn't work:
for (oElement in aElts){
var oElement = aElts[i];
if (oElement.id)
if (oElement.id == 'alert2')
oElement.onclic k = Alert;
}
}
Why?
I am attaching two testcases (testcase A works, testcase B doesn't work;
and the JS Console is not warning about anything).
Thanks in advance.
knocte
Comment