jQuery event.currentTarget 属性
实例
event.currentTarget 通常等于 this:
<!DOCTYPE html><html><head><script src="https://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script><script>$(document).ready(function(){$("h1, h2, p").click(function(event){alert(event.currentTarget === this);});});</script></head><body><h1>Heading 1</h1><h2>Heading 2</h2><p><b>注意:</b> 单击每个 HTML 元素。currentTarget 通常等于 "this",并将返回 "true"</p></body></html>
定义与用法
event.currentTarget 属性是事件冒泡阶段中的当前 DOM 元素,通常等于 this。
语法
event.currentTarget
| 参数 | 描述 |
|---|---|
| event | 必填。event 参数来自事件绑定函数 |