最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jQuery: onclick drop-down menu with controls - Stack Overflow

programmeradmin0浏览0评论

I wish to create a menu (a sign-up menu), see this to get an idea of it. When user clicks on this button/link a drop-down menu appears, using which he can do something (here login).

The behaviour of the link should be the following:

  1. The drop-down menu should appear when clicked on this button/link.
  2. when clicked anywhere on the page (including the button/link itself), but outside the menu, the menu should disappear.
  3. If clicked somewhere on the drop-down menu, the menu should not disappear.
  4. All the controls in the drop-down menu should work.

I did somehow managed to get first three working, but then the controls within the drop-down menu (4th behaviour) are not working.

The javascript/jQuery code along with html code is given here (jsfiddle link, same as above). You can fork it and make changes.

Thanks.

I wish to create a menu (a sign-up menu), see this to get an idea of it. When user clicks on this button/link a drop-down menu appears, using which he can do something (here login).

The behaviour of the link should be the following:

  1. The drop-down menu should appear when clicked on this button/link.
  2. when clicked anywhere on the page (including the button/link itself), but outside the menu, the menu should disappear.
  3. If clicked somewhere on the drop-down menu, the menu should not disappear.
  4. All the controls in the drop-down menu should work.

I did somehow managed to get first three working, but then the controls within the drop-down menu (4th behaviour) are not working.

The javascript/jQuery code along with html code is given here (jsfiddle link, same as above). You can fork it and make changes.

Thanks.

Share Improve this question asked Feb 4, 2012 at 3:40 user1144616user1144616 1,2512 gold badges15 silver badges16 bronze badges 1
  • Hah! I just asked more or less the same question ... you can see my (slightly broken) solution here: stackoverflow./questions/9138236/jquery-easy-pulldown-menu – designosis Commented Feb 4, 2012 at 3:48
Add a ment  | 

2 Answers 2

Reset to default 4

check this

http://thefinishedbox./files/freebies/loginfreebie/index.html

Download tha code

http://thefinishedbox./freebies/scripts/jquery-dropdown-login/

I made a fork of what you have on your jsFiddle: http://jsfiddle/DukyJ/

If you look at the code I just added an extra div to have the page's content so I don't have to assign click events to the whole body just only to that div. Then, I removed the return false and the stopProppagation and just added a '#' to the link in the href because it wasn't necesary. And finally just added some style to the signin link and the singin panel so you can see that the menu appears over the content as I suppose you want it to appear.

发布评论

评论列表(0)

  1. 暂无评论