次の点を考慮してください。
<div onclick="alert('you clicked the header')" class="header">
<span onclick="alert('you clicked inside the header');">something inside the header</span>
</div>
ユーザーがスパンをクリックしたときに、div
クリック イベントが発生しないようにするにはどうすればよいですか?
ベストアンサー1
<span onclick="event.stopPropagation(); alert('you clicked inside the header');">something inside the header</span>
IEの場合:window.event.cancelBubble = true
<span onclick="window.event.cancelBubble = true; alert('you clicked inside the header');">something inside the header</span>