[問題] off('mouseenter') 的問題

看板Ajax作者 (愛是一種忍耐)時間14年前 (2012/06/25 15:19), 編輯推噓0(002)
留言2則, 2人參與, 最新討論串1/1
我嘗試用 .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
打錯字而已...mouseente要改成mouseenter
06/26 02:16, 1F

06/26 08:08, , 2F
sorry我這邊範例打錯字了 可我的程式還是掛 我比較一下
06/26 08:08, 2F
文章代碼(AID): #1Fw140p5 (Ajax)
文章代碼(AID): #1Fw140p5 (Ajax)