<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script src="jquery-1.10.1.min.js"></script>
<script>
$(function(){
$('#div1').on('click',{name:'hello'},function(ev){
alert(ev.data.name); // 传递参数
alert( ev.target ); // 当前操作的事件源
alert( ev.type ); // 当前操作的事件类型
});
});
</script>
</head>
<body>
<div id="div1">aaaa</div>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script src="jquery-1.10.1.min.js"></script>
<script>
$(function(){
$('#div1').on('click',{name:'hello'},function(ev){
alert(ev.data.name); // 传递参数
alert( ev.target ); // 当前操作的事件源
alert( ev.type ); // 当前操作的事件类型
});
});
</script>
</head>
<body>
<div id="div1">aaaa</div>
</body>
</html>
本文介绍了一个使用jQuery实现的简单点击事件示例。通过为页面上的一个div元素绑定点击事件,展示了如何利用jQuery来处理用户交互,并传递参数、获取事件源及事件类型等关键信息。
340

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



