jquery点击其他位置 下拉导航隐藏
<script>
$(function(){
$(".dropdown").click(function(e){
$(".dropdown").removeClass('open');
$(this).toggleClass('open');
});
//$("body").bind("click",function(evt){
//if(evt.target!=$('.dropdown-menu').get(0)){
//$('.dropdown-menu').hide();
//}
//});
$(document).bind("click",function(e){
vartarget=$(e.target);
if(target.closest(".dropdown").length==0){
$(".dropdown").removeClass('open');
}
})
//如果当前点击的不是.dropdown标签,那么去掉.dropdown上的.open class.
})
</script>
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。