首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >JQuery中事件是否发生的判断

JQuery中事件是否发生的判断

作者头像
大黄大黄大黄
发布于 2018-09-14 18:12:27
发布于 2018-09-14 18:12:27
2.3K0
举报

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sinat_35512245/article/details/52916004

$(document).ready(function () {     $("html").click(function (e) {         if (e.target == $("#id/.class")[0]) {             //函数体         }     }); });

target 属性规定哪个 DOM 元素触发了该事件。

$("p, button, h1, h2").click(function(event){   $("div").html("Triggered by a " + event.target.nodeName + " element."); });

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2016年10月24日,如有侵权请联系 cloudcommunity@tencent.com 删除
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档