August 29, 200917 yr I've got a multilevel menu. At the moment i'm using this $('#menu li a[href="#"]').click(function() { $('#menu').stop().animate({height: "75px"}); return false; }); Which works fine, because i know that anything that contains a sublevel is only a # But just for expandability and graceful degradation i want to check for a nested <ul> element, if one is found then i want to return false on the link, if one isn't found then i want to follow the link through. I've tried all sorts, but i've not had any luck. Anyone know?
August 30, 200917 yr That should be doable, although I have never needed to do it. Try this: if ( $("#myid").length > 0 ) { //perform an action }
August 30, 200917 yr There's a Children function that should help with this. Just call it on the hovered element and check the length.
September 6, 200917 yr you can try if ( $('#menu li a[href="#"]' ).next().is('ul')) { //perform an action } i have that working on a menu. If you are just checking the specific link you click you can use if ( $(this).next().is('ul')) { //perform an action }
Create an account or sign in to comment