简体   繁体   中英

Dropdown Menu - Links do not work

I have a good working dropdown menu on my website, however, it didn't close when I clicked somewhere else on the page. It took me a while but I got this code written to get rid of this problem:

$(document).ready(function(e) {
    $(".submenus").click(function( ) {
        $(this).toggleClass('tap');       
        return false;
     });

    $(document).click(function( ) {
    $(".submenus").removeClass('tap');
    });
 });

Now another new problem occurd. Like I have said, the menu works perfectly, but since I have added this new code, the links within the menu do not open anymore when clicking on them, however, they do open when I right click and then open it in a new window. My assumption is that this new code closes the links before the code gives the website the task to open the link. That way it will try to open something it cant fint. That's my assumption, but do not know how I could solve this.

Thanks for your help, Jan

好了,由于上面收到的提示,我弄清楚了,我需要用“ event.stopPropagation();”代替“ return false”。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM