2011-12-06 4 views
0

다음 질문은 여러분에게 쉬운 일 이겠지만, 저는 여전히 jQuery에 대해 고민하고 있습니다.jquery 풀다운 메뉴

버튼이 있다고 가정 해 보겠습니다. 마우스를 올리면 div가 버튼 아래쪽으로 내려 가고 풀다운 메뉴를 나타냅니다. 내가 버튼을 가리키고 있지 않을 때 메뉴가 그대로 있어야하지만 버튼을 가리키면 켜지도록 설정되어 있기 때문에 분명히 아닙니다. 다른 버튼을 가리키면 어떻게 메뉴를 유지하고 끌 수 있습니까?

감사합니다.

+0

당신의 몇 가지 예를 포함 할 수 있다면 도움이 될 것를 다른 사람들이 당신이 의미하는 바를 더 잘 이해할 수 있도록 함께 작업하는 코드. – 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.