I’m trying to make a jquery toggle menu for a mobile website.
I’ve managed to create a toggle menu with + and – when toggled and when not
Current version: http://jsfiddle.net/9Dvrr/7/
Now i’m trying to create a if else statement fot displaying a “>” when there are no children.
Experiment: http://jsfiddle.net/9Dvrr/6/
Problem is that i just can seem to figure it out..
Thanks in advance,
Rick
You need to check the length property when checking if it has children. Otherwise, all you’re checking is if the result is non-null or not…and it will always be non-null even if the selector doesn’t match because it will return jQuery. It will be empty of any elements, but an object nonetheless and thus non-null.