[問題] off('mouseenter') 的問題
我嘗試用 .off("mouseenter", handler);
但是不發生作用 程式如下
http://jsfiddle.net/7bPnP/11/
<button id="theone">Does nothing...</button>
<button id="bind">Add Click</button>
<div id='msg' style="display:none;">Click!</div>
<div id="thetwo" style="width:200px;height:200px;background-color:red"></div>
$(document).ready( function() {
function aClick() {
$("#msg").show().fadeOut("slow");
$("#theone").off("click", aClick)
.text("Does nothing...");
}
$("#bind").click(function () {
$("#theone").on("click", aClick)
.text("Can Click!");
});
});
$(document).ready( function() {
function aenter() {
alert('mouse enter');
$("#thetwo").off("mouseente", aenter);
}
$("#thetwo").on("mouseenter", aenter);
});
主要是 $("#thetwo").off("mouseente", aenter);
是放在 handler function中
如果不是放在handler function中 就會正常被取消
而第一段程式 $("#theone").off("click", aClick)
off click放在 handler function中也正常
所以同樣是將off放在handler function中
click正常 mouseenter卻失敗
這是bug嗎 不知道有沒有人試過
--
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 175.181.46.55
→
06/26 02:16, , 1F
06/26 02:16, 1F
→
06/26 08:08, , 2F
06/26 08:08, 2F
Ajax 近期熱門文章
PTT數位生活區 即時熱門文章