• 0

Simple dropdown click jQuery


Question

I'm not good at jQuery and would like to be able to click and the menu would drop down. I'm trying to do it but its not working. Here is my sample. Want to do it instead of hover so people can use it on menu.

 

http://cssdeck.com/labs/0pgruqby

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0

Change:

 

$(this).find('ul')
to

 

$(this).parent().find('ul')
The ul isn't in the <a>, it's in the parent li.

Also, you refer to a.dropdown, which doesn't exist - that means: a with the class dropdown.

Link to comment
Share on other sites

  • 0

Lots of things wrong here.

Your selector is wrong. Theres no a with a class of dropdown. 

Theres no such function as onclick either. 

Link to comment
Share on other sites

  • 0

Yea, Trying to fix it now but no go. I made changes but not working.

Link to comment
Share on other sites

  • 0

Yea, Trying to fix it now but no go. I made changes but not working.

Pretty simple and you can use slideToggle to cut down on your repetition too. Just add a class to your first unordered list and then change your jQuery to the following(i would target the list item as opposed to the anchor tag which you dont need):

$('ul.main li').click(function(){
     $(this).find('ul').slideToggle();
});
Link to comment
Share on other sites

  • 0

Try that and still no go.

 

 

Pretty simple and you can use slideToggle to cut down on your repetition too. Just add a class to your first unordered list and then change your jQuery to the following(i would target the list item as opposed to the anchor tag which you dont need):

$('ul.main li').click(function(){
     $(this).find('ul').slideToggle();
});
Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.