<html>
<head>
<meta charset=" gb2312">
<title>事件冒泡</title>
<script type="text/javascript" src="mytest/jQuery/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#second").click(function(){
alert("我是second");
})
$("#first").click(function(){
alert("我是first");
})
})
</script>
</head>
<body>
<p id="first"><a id="second" href="http://www.baidu.com">点击查看效果</a></p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<head>
<title>事件冒泡</title>
<style type="text/css">
#grandfather{
border:1px solid #0066FF;
cellpadding:0px;
cellspacing:0px;
}
#grandfather td{
border: 1px solid #0066FF;
}
</style>
<script type="text/javascript">
function trclick(){
alert("父亲的onclick事件触发");
}
function tableclick(){
alert("祖父的onclick事件触发");
}
window.onload=function(){
var grandfather=document.getElementById("grandfather");
var father=document.getElementById("father");
var noStop=document.getElementById("noStop");
var haveStop=document.getElementById("haveStop");
grandfather.onclick=tableclick;
father.onclick=trclick;
noStop.onclick=function(){
alert("没有阻止冒泡的子元素");
}
haveStop.onclick=function(evt){
alert("阻止冒泡的子元素");
if(window.event){
event.cancelBubble=true;
}
else if(evt){
evt.stopPropagation();
}
}
}
</script>
</head>
<body>
<table width="204" id="grandfather">
<tr >
<td width="96"></td>
<td width="96"></td>
</tr>
<tr id="father">
<td id="noStop">没有阻止事件冒泡</td>
<td id="haveStop">阻止了事件冒泡</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有