이 작업을 수행하는 방법에는 여러 가지가 있습니다.
function doprocess2(e) {
e.stopPropagation && e.stopPropagation() || (e.cancelBubble = true);
...
}
과 같이 호출 :
같이 doprocess2 정의 :
이
onclick="doprocess2(event);"
이 또한 6으로 모든 최신 브라우저에서 작동합니다 귀하의 경우 가장 쉬운에서 은 다음 아마도 , ie7 & ie8
다음은 유용한 예제입니다.
<html>
<head>
<script>
function doprocess1() { alert('tr'); }
function doprocess2(e) {
e.stopPropagation && e.stopPropagation() || (e.cancelBubble = true);
alert('td');
}
</script>
</head>
<body>
<table>
<tr onclick="doprocess1();">
<td>click tr</td>
<td><button onclick="doprocess2(event);">click td only</button></td>
</tr>
</table>
</body>
</html>