首页 > Web开发 > 详细

js/jquery实现点击div层外,隐藏div

时间:2016-04-30 02:20:53      阅读:313      评论:0      收藏:0      [点我收藏+]

js

document.onmousedown=function(e){
    var target = e.target;
    //alert(target.id);
    var sea = target.getAttribute("sea");
    if(sea!="sea"){
    	if(get("seaList").style.display!="none"){
    		get("seaList").style.display="none";
		}
    }
};

?

jquery

$(document).bind(‘click‘,function(e){
	var target = jQuery(e.target);
	//alert(target.attr("id"));
	alert(target.closest(".seaVal").length+","+target.closest(".seaList").length);
	if(target.closest(".seaVal").length!=1&&target.closest(".seaList").length!=1)
	{
		if($(".seaList").show()){
			$(".seaList").hide();
		}
	}
});

?

js/jquery实现点击div层外,隐藏div

原文:http://zihai367.iteye.com/blog/2294657

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!