간단한 드롭 다운 스크립트가 있는데 메뉴 바깥 쪽을 클릭하여 열려있는 모든 드롭 다운을 숨기고 싶습니다. 그러나 작동하지 않는 것 같습니다. 왜 그 이유를 알고 있습니까?메뉴 바깥 쪽을 클릭 할 때 숨기는 드롭 다운
여기에서 찾을 수 있습니다 : http://codepen.io/dr-potato/pen/rLleC?editors=101
HTML
<ul>
<li><a href="#">Home</a></li>
<li class="Navigation-listItem is-dropdown">
<a href="#">About</a>
<ul class="Navigation-list is-dropdown is-hidden">
<li>Johnny</li>
<li>Julie</li>
<li>Jamie</li>
</ul>
</li>
<li class="Navigation-listItem is-dropdown">
<a href="#">Contact</a>
<ul class="Navigation-list is-dropdown is-hidden">
<li>Johnny</li>
<li>Julie</li>
<li>Jamie</li>
</ul>
</li>
</ul>
당신은 당신의 드롭 다운의 표시 속성을 변경할 수 있습니다
$(document).ready(function() {
$('.Navigation-listItem').click(function() {
$(this).children('.Navigation-list.is-dropdown').toggleClass('is-hidden');
});
});
/* Anything that gets to the document
will hide the dropdown */
$(document).click(function(){
$(".Navigation-listItem.is-dropdown").addClass('is-hidden');
});
/* Clicks within the dropdown won't make
it past the dropdown itself */
$(".Navigation-listItem.is-dropdown").click(function(e){
e.stopPropagation();
});
드롭 다운이 나타나지 않는 것 같습니다. – 4dgaurav
@ Gaurav : 죄송합니다. JS –
@ Gaurav에 맞춤법 오류가 있지만 문제는 여전히 지속됩니다. –