<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题页</title>
<script src="jquery-1.10.2.js" type="text/javascript"></script>
<style type="text/css">
.waiting{color:gray};
</style>
<!--事件-->
<script type="text/javascript">
$(function(){
$('#tr1').click(function(e){
alert('下面是tr的');
//this 是随不同的当前监听元素变动的
alert($(this).html());
//最原始触发事件的元素
alert($(e.target).html());
});
$('#tb1').click(function(e){
alert('下面是tb的');
alert($(this).html());
alert($(e.target).html());
});
$(":button").click(function(){
//alert(1);
});
//只调用一次
$(":button").one("click",function(){
alert(2);
});
});
</script>
</head>
<body>
<table id="tb1">
<tr id="tr1">
<td id="td1"><p id="tp1">冒泡</p></td>
</tr>
</table>
<input type="button" value="click"/>
</body>
</html>
Jquery系列-Jquery事件2 this与e.target
最新推荐文章于 2022-12-01 12:01:44 发布