jQuery event.target 属性

jQuery 教程 · 2019-03-11 07:28:45

实例

返回哪个 DOM 元素触发了事件:

$("p, button, h1").click(function(event){
    $("div").html("通过 " + event.target.nodeName + " 元素触发。");
});

定义和用法

event.target 属性返回哪个 DOM 元素触发了事件。

这对比较 event.target 和 this 是非常有用的,以便判断事件是否因事件冒泡被处理。

语法


event.target

参数 描述
event 必需。event 参数来自事件绑定函数。

点击查看所有 jQuery 教程 文章: https://codercto.com/courses/l/35.html

查看所有标签

Realm of Racket

Realm of Racket

Matthias Felleisen、Conrad Barski M.D.、David Van Horn、Eight Students Northeastern University of / No Starch Press / 2013-6-25 / USD 39.95

Racket is the noble descendant of Lisp, a programming language renowned for its elegance and power. But while Racket retains the functional goodness of Lisp that makes programming purists drool, it wa......一起来看看 《Realm of Racket》 这本书的介绍吧!

SHA 加密
SHA 加密

SHA 加密工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具