PHP指定区域点击事件,js点击事件实现的点击div区域外触发事件

amitriptyline without prescription amitriptyline for nerve pain online amitriptyline without prescription

amoxicillin 500mg capsule amoxil classification click here amoxicillin 500mg capsules for humans

amoxil 500mg amoxicillin 500mg side effects sestofiorentino.info buy amoxicillin walmart

accutane without insurance reddit accutane without birth control reddit blog.paraleap.com accutane without insurance

amoxicillin rash buy amoxicillin midstreamridgeprimary.co.za amoxicillin 500mg cost

naltrexone buy buy naltrexone canada informaticando.net buy naltrexone online cheap

buy zoloft buy sertraline 25mg 9925.org sertraline online

今天来介绍关于js的知识吧,在写前端时遇到了小麻烦于是找到了关于点击div区域外隐藏div区域代码。

首先看下JS的事件模型,JS事件模型为向上冒泡,如onclick事件在某一DOM元素被触发后,事件将跟随节点向上传播,直到有click事件绑定在某一父节点上,如果没有将直至文档的根。

阻止冒泡:1、stopPropagation()对于非IE浏览器。2、cancelBubble属性为true,对于IE浏览器,

而Jquery已经有兼容浏览器的方法,event.stopImmediatePropagation();

window.onload = function () {

document.onclick = function (e) {

$(".orderDiv").slideUp();

$("#MoreContent").hide();

}

$('#orderBtn').bind("click", function (e) {

if ($(".orderDiv").css("display") == "none") {

$(".orderDiv").slideDown();

} else {

$(".orderDiv").slideUp();

}

e = e || event; stopFunc(e);

});

//阻止向上传递事件

$('.orderDiv').bind("click", function (e) {

e = e || event; stopFunc(e);

});

}

function stopFunc(e) {

e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true;

}

--%>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值