Reputation: 1262
im just curious about this proper code. im happy if some can correct this and explain a little about this.
$('.parentmenu:nth-child(1)').addClass('on', function(){
$(this+'ul').delay(500).slideDown();
});
I would like to use the same class element as for this referring and add UL element to trigger the navigation slide-down. I would like to know what is the correct format.
Or is there a way to shorten this code? Thanks in advance.
Upvotes: 0
Views: 55
Reputation: 1262
yeah it works on single but not inside the addClass. so i refine my codes to this base on your answers.
$('.parentmenu:nth-child(1)').addClass('on').find('ul').delay('500').slideDown();
This fully worked out the child menu sliding down effect with the adding class on for parent menu hover activation.
Thanks for your help guys.
Upvotes: 0
Reputation: 356
I dont think addClass accepts a callback. A readable line would be
$('.parentmenu').addClass('on')
.children('ul').delay(500).slideDown();
Upvotes: 1
Reputation: 298106
I've never heard of a callback for addClass()
.
Try this instead:
$('.parentmenu').first().addClass('on').find('ul').delay(500).slideDown();
Upvotes: 1
Reputation: 55740
I have never heard .addClass()
having any callbacks
This is a wrong syntax..
.addClass('on', function(){
Maybe you are looking for this
$('.parentmenu:nth-child(1)').find('ul').delay(500).slideDown();
Upvotes: 1
Reputation: 6051
you can either
$('ul',this).delay(500).slideDown();
or
$(this).find('ul').delay(500).slideDown();
either should work.
Upvotes: 1