87,996
社区成员




<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
</head>
<body>
<div onclick="foo1()" style="width:600px;height:100px;background-color:#CCC;">
<div onclick="foo2()" style="width:100px;height:50px;background-color:#666;"></div>
</div>
<script>
function foo1()
{
alert("1");
}
function foo2()
{
alert("2");
}
</script>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
</head>
<body>
<div onclick="foo1()" style="width:600px;height:100px;background-color:#CCC;">
<div id="innerTag" style="width:100px;height:50px;background-color:#666;"></div>
</div>
<script>
function foo1()
{
alert("1");
}
document.getElementById("innerTag").onclick=function(event) {
event.stopPropagation();
alert("2");
}
</script>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
</head>
<body>
<div onclick="foo1()" style="width:600px;height:100px;background-color:#CCC;">
<div onclick="foo2()" style="width:100px;height:50px;background-color:#666;"></div>
</div>
<script>
function foo1()
{
alert("1");
}
function foo2()
{
alert("2");
event.stopPropagation();
}
</script>
</body>
</html>
function foo2()
{
alert("2");
return false;
}
function amIclicked(e, element)
{
e = e || event;
var target = e.target || e.srcElement;
if(target.id==element.id)
return true;
else
return false;
}
function oneClick(event, element)
{
if(amIclicked(event, element))
{
alert('One is clicked');
}
}
function twoClick(event, element)
{
if(amIclicked(event, element))
{
alert('Two is clicked');
}
}