div内的button的click会触发两次(防止事件冒泡)
生活随笔
收集整理的這篇文章主要介紹了
div内的button的click会触发两次(防止事件冒泡)
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
<html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><title>阻止事件冒泡</title><script type="text/javascript">function SayHello(e) {alert("Hello World");e = window.event || e;if (e.stopPropagation) {e.stopPropagation();} else {e.cancelBubble = true;}}</script></head><body><form id="form1" runat="server"><div οnclick="SayHello(event)" style="width:300px; height:300px; background-color:Green"><input type="button" value="click me" οnclick="SayHello(event)" /></div></form></body></html>
?
總結(jié)
以上是生活随笔為你收集整理的div内的button的click会触发两次(防止事件冒泡)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 松本行弘访谈录
- 下一篇: 三种监控平台配置及其整合(cacti n