2011-12-06 7 views
0

次の質問は皆さんにとっては簡単かもしれませんが、私はまだjQueryについて頭を悩ませています。jqueryプルダウンメニュー

私はボタンがあるとしましょう。私がマウスを動かすと、divはボタンの一番下にスライドし、プルダウンメニューを表します。私はボタンをホバリングしていないときにメニューはまだそこにあるはずですが、私はボタンをホバーするときに私はそれがオンになるように設定しているので、明らかにそうではありません。別のボタンをホバーすると、メニューを保持してそれをオフにするにはどうすればいいですか?

ありがとうございました。

+0

これは(tanduの答えに似ていますが、私はそう、私はまだそれを投稿するつもりです、それに取り組んでいた)何が必要です他の人があなたが意味することをより良く理解できるように、作業しているコード。 – mason81

答えて

0
Hi as you are using hover event to show your pull down menu, you can keep your menu visible even you move your cursor from the button and to hide the menu you can use the following code, which runs on your mouse click anywhere else in the document. 

    // for taks sum menus (to remove if user clicks anywhere else) 
    $(document).mouseup(function (e) 
       { 
        var container = $(".submenu"); //menu div class 

        if (!container.is(e.target) // if the target of the click isn't the container... 
         && container.has(e.target).length === 0) // ... nor a descendant of the container 
        { 
         container.hide(); 
        } 
       }); 

I hope this will help you. 
関連する問題