bind()、toggle()和hover()
点击依次执行,第一个事件,第二个事件
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body>
<input type="button" id="btn" value="触发" />
<script src="jQuery Core 1.9.1.js"></script>
<script>
$("#btn").bind("click",function(){
alert("第一个事件");
alert("第二个事件");
})
</script>
</body>
</html>
同上
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body>
<input type="button" id="btn" value="触发" />
<script src="jQuery Core 1.9.1.js"></script>
<script>
$("#btn").bind("click",function(){
alert("第一个事件");
}).bind("click",function(){
alert("第二个事件");
})
</script>
</body>
</html>``
`“
jQuery事件绑定示例
本文通过两个HTML示例演示了如何使用jQuery的bind()方法来为DOM元素绑定多个click事件。当按钮被点击时,会依次触发绑定的事件处理函数,并弹窗显示对应的事件消息。
525

被折叠的 条评论
为什么被折叠?



