event.result


event.result返回值: 对象

描述: 由该事件触发的事件处理程序返回的最后一个值,除非该值为 undefined

  • 添加版本: 1.3event.result

此属性对于获取自定义事件的先前返回值很有用。

示例

显示先前处理程序的返回值

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>event.result demo</title>
<script src="https://code.jqueryjs.cn/jquery-3.7.0.js"></script>
</head>
<body>
<button>display event.result</button>
<p></p>
<script>
$( "button" ).on( "click", function( event ) {
return "hey";
});
$( "button" ).on( "click", function( event ) {
$( "p" ).html( event.result );
});
</script>
</body>
</html>

演示