<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(){
$("#p0").mouseenter(function(){
$(this).text("来了");
});
$("#p0").mouseleave(function(){
$(this).text("走了");
});
$("#p1").hover(
function(){
$(this).text("来了")
},
function(){
$(this).text("走了")
});
$('#tp1').click(function(){
alert('tp1 被点了');
})
$('#td1').click(function(){
alert('td1 被点了');
})
$('#tr1').click(function(e){
//阻止冒泡
e.stopPropagation();
//阻止默认事件 与 Window.event.returnValue=false一样
e.preventDefault();
alert('tr1 被点了');
})
$('#tb1').click(function(e){
e.stopPropagation();
alert('tb1 被点了');
})
});
</script>
</head>
<body>
<p id="p0">您好</p>
<hr/>
<p id="p1">hover</p>
<hr />
<table οnclick="alert('table')">
<tr οnclick="alert('tr')">
<td οnclick="alert('td')"><p οnclick="alert('p')">冒泡</p></td>
</tr>
</table>
<table id="tb1">
<tr id="tr1">
<td id="td1"><p id="tp1">冒泡</p></td>
</tr>
</table>
</body>
</html>
Jquery系列-Jquery事件
最新推荐文章于 2017-04-09 14:09:33 发布