How to get dropdown menu to open/close on click rather than hover?

后端 未结 5 1666
星月不相逢
星月不相逢 2021-02-06 07:32

I am very new to javascript and ajax/jquery and have been working on trying to get a script to open and close the drop menu on click rather that hover.

The menu in quest

5条回答
  •  梦谈多话
    2021-02-06 08:26

    if you need two functions for a click event, try .toggle

    i'm using this:

    $('.triggerlist').toggle(function(e) {
            e.preventDefault();
      $(this).find('ul').fadeIn();
        },function() {
      $(this).find('ul').fadeOut();
        });
    

    Which allows me to do more stuff on the 2 functions than just the .click with its 1 function.

提交回复
热议问题