T
tukaopaleye
Hi,
I am trying to use the prototype.js library and trying to substitute:
for (var index = 0; index < elementArray.length; ++index) {
var e = elementArray[index];
if (e.id.include(controlId))
{
return e;
}
}
which i want to express as:
elementArray.each(function(elem){
if (elem.id.include(controlId))
{
return elem;
}
});
It seems that the return element is ignored and the loop just
continues even if the condition is evaluated to true. in the
documentation, http://www.prototypejs.org/api/enumerable/each it
says that return is usable but I am not clear how, I am tringto avaid
the deprecated $continue and $break...
TIA,
I am trying to use the prototype.js library and trying to substitute:
for (var index = 0; index < elementArray.length; ++index) {
var e = elementArray[index];
if (e.id.include(controlId))
{
return e;
}
}
which i want to express as:
elementArray.each(function(elem){
if (elem.id.include(controlId))
{
return elem;
}
});
It seems that the return element is ignored and the loop just
continues even if the condition is evaluated to true. in the
documentation, http://www.prototypejs.org/api/enumerable/each it
says that return is usable but I am not clear how, I am tringto avaid
the deprecated $continue and $break...
TIA,