<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div {
padding: 20px;
border: 1px solid #000;
}
</style>
</head>
<body>
<div onclick="fn('爸爸')">爸爸
<div onclick="fn('儿子')">儿子
<div onclick="fn('孙子')">
孙子
</div>
</div>
</div>
</body>
</html>
<script>
function fn(v) {
// window.event.cancelBubble = true 兼容ie
window.event ? window.event.cancelBubble = true : event.stopPropagation();
alert(v)
}
</script>
06-30
8073