我有一個按鈕,裏面有一個跨度。我有一個點擊事件的按鈕,我也有一個點擊事件的跨度,但在IE11跨度點擊事件不是射擊(在Chrome/Firefox中工作)。有沒有任何解決方法,這不從一個按鈕更改爲div?點擊事件裏面的按鈕不在IE中觸發
我知道,改變我的按鈕到一個div將工作(如其他問題回答),我想避免這樣做。
https://jsfiddle.net/asjo8ox0/2/
$(document)
.on("click", ".parent", function() {
alert("parent");
})
.on("click", ".child", function(e) {
alert("child");
e.stopPropagation();
})
.parent {
width: 200px;
height: 200px;
background-color: cornflowerblue;
}
.child {
width: 100px;
height: 100px;
background-color: white;
display: none;
}
.parent:hover .child {
display: block;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button class="parent">
<span class="child"></span>
</button>
您正在嘗試的IE版本? –
@NagaSaiA我在IE11中測試這個,將這個添加到我的問題中 – philr
e不存在於您的點擊事件中... on(「click」,「.child」,function(e){ alert 「孩子」); e.stopPagagation(); }) – serverSentinel