时间:2021-07-01 10:21:17 帮助过:9人阅读
<!DOCTYPE html>
<html>
<head>
<title>Bubbling</title>
<style type="text/css">
* {
font-size:30px;
}
div {
border: 1px blue solid;
}
span {
border: 1px blue solid;
}
</style>
<script type="text/javascript">
function setforeColor(sender) {
sender.style.color = "red";
}
function setbgColor(sender) {
sender.style.background = "green";
return false;
}
</script>
</head>
<body>
<div>
<span onclick="setforeColor(this)">span tag</span> in div
</div>
<br>
<div>
<input type="button" value="Button" onclick="setforeColor(this)"/> in div
</div>
<br>
<a href="https://www.baidu.com" style="text-decoration:none;display:block;">
<span onclick="setforeColor(this);return false">span tag</span> in anchor
</a>
<br>
<a href="https://www.baidu.com" style="text-decoration:none;display:block;">
<span onclick="setbgColor(this)">span tag</span> in anchor
</a>
</body>
</html>以上就是如何实现Html事件冒泡的详细内容,更多请关注Gxl网其它相关文章!