as part of a script i am working on i have the following:
loop
if($(element).find(selector))
{ do stuff }
else
{ do other stuff }
/loop
The idea is that there are two versions of the elements getting looped and I need to distinguish between them (based on content) to determine which actions to take.
This works great if find is successful. If it is not, then the script has a fatal error.
I can’t find any documentation on what happens when find fails. How do I make this work?
How about this?
It’s a little longer, but ought to work.
Looks to me like your original find test always evaluates to true. Testing the length gets you a boolean result to evaluate.