小编ish*_*dev的帖子

在jQuery ajax加载或更新后,我丢失了mouseover事件

在使用.load更新我的div后,即将项添加到我的列表中,我使用了firebug并看到列表已更新.但是,我丢失了鼠标悬停事件,该事件在页面首次加载时起作用....在我的脚本中我有:

// hide and show are css classes that display none and block respectively

function openList(){
    $("#miniList").removeClass().addClass("show");
}
function closeList(){
    $("#miniList").removeClass().addClass("hide");
}
...
$(document).ready(function() {
    $("#miniList").mouseover(function() {
        openList();
    })
    $("#miniList").mouseout(function() {
        closeList();
     })
});
Run Code Online (Sandbox Code Playgroud)
function addItemToDiv(id, ref, num) {
    $("#miniList").load("/list/ajax_updateList.jsp", {
        'action' : 'additem',
        'pid' : id,
        'pref' : ref,
        'qty' : num
    });
}
Run Code Online (Sandbox Code Playgroud)

...当然,这在第一次加载页面时工作正常,但是当我将项目添加到列表时,DOM会更新,但鼠标悬停效果不再起作用.

任何想法都受到欢迎.提前谢谢了.

javascript ajax jquery javascript-events

5
推荐指数
1
解决办法
4977
查看次数

标签 统计

ajax ×1

javascript ×1

javascript-events ×1

jquery ×1