简体   繁体   English

jQuery Mouseover / Mouseout 不适用于 Live

[英]jQuery Mouseover / Mouseout will not work with Live

I have code that when I do an ajax call, it refreshes a column but then the mouseover no longer works.我有代码,当我进行 ajax 调用时,它会刷新一列,但鼠标悬停不再有效。 I used to have it inline in the div but wanted to move it to jQuery for other reasons.我曾经将它内嵌在 div 中,但出于其他原因想将其移动到 jQuery。 this is my code.这是我的代码。

$(".statusbox").live({mouseover:function(){
    wal_id = parseInt(this.id.replace("statuscontainer_", ""));
    $('#rm_'+wal_id).show();
},mouseout:function(){
    wal_id = parseInt(this.id.replace("statuscontainer_", ""));
    $('#rm_'+wal_id).hide();}
});

Any ideas?有任何想法吗?

This is the correct syntax for live:这是 live 的正确语法:

$(".statusbox").live( 'mouseover', function() {} );

Try尝试

$(".statusbox").live( 'mouseover', function() {
    wal_id = parseInt(this.id.replace("statuscontainer_", ""));
    $('#rm_'+wal_id).show();
}).live('mouseout', function() {
    wal_id = parseInt(this.id.replace("statuscontainer_", ""));
    $('#rm_'+wal_id).hide();}
});

Try this:试试这个:

$(".statusbox").live("hover", function(){
   ...
}, function(){
   ...
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM