Hello, hopefully someone can help. I am trying to fiddle with Prototype JS and have a question about a basic collapsible nav structure I am trying to build.
The following works well except for one thing. I would like for the JS to identify if the child or 'next' DOM element is empty to not fire.
The code is:
Event.observe(document, 'dom:loaded', function() {
$$('#leftnav li a').each(function(element) {
Event.observe(element, 'click', function(event){
Event.stop(event);
Event.element(event).next(0).toggle();
Event.element(event).up(0).toggleClassName('active');
},
false);
});
});
So if there not a nested 'UL', don't fire. When I try to break this out into an if else, it seems to fail no matter what.
Thoughts or suggestions?
Thanks!