admin管理员组文章数量:1420929
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:
- The drop-down menu should appear when clicked on this button/link.
- when clicked anywhere on the page (including the button/link itself), but outside the menu, the menu should disappear.
- If clicked somewhere on the drop-down menu, the menu should not disappear.
- 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:
- The drop-down menu should appear when clicked on this button/link.
- when clicked anywhere on the page (including the button/link itself), but outside the menu, the menu should disappear.
- If clicked somewhere on the drop-down menu, the menu should not disappear.
- 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
2 Answers
Reset to default 4check 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.
本文标签: javascriptjQuery onclick dropdown menu with controlsStack Overflow
版权声明:本文标题:javascript - jQuery: onclick drop-down menu with controls - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745340999a2654260.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论