日期:2014-05-16  浏览次数:20397 次

如何只触发这样的效果
<li onclick="show()"><a onclick="showtime()">确定</a><li>
现在点击确定时会同时触发2个事件,要怎样才能点确定只触发showtime,
注:show()这个方法也有用,不能删除
jquery? javascript 触发事件

------解决方案--------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function show(){
alert('f');
}
function showtime(e){
alert('f_');
e.stopPropagation();
}
</script>
</head>

<body>
<li onclick="show()"><a onclick="showtime(event)">确定</a><li>
</body>
</html><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function show(){
alert('f');
}
function showtime(e){
alert('f_');
e.stopPropagation();
}
</script>
</head>

<body>
<li onclick="show()"><a onclick="showtime(event)">确定</a><li>
</body>
</html>