You are using .each()
with a function
.each(function(){
...
return this;
});
return false;
This will return from the callback (and maybe stop the each-loop if this
was false
), but never break out and return from the outer getCurrentCell
function! So, that one will always return false
.
Quick fix:
var result = false;
<...>.each(function(){
if (<condition>) {
result = <found element>;
return false; // break each-loop
}
});
return result; // still false if nothing found