Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用ajax内容在JQuery中悬停显示/隐藏div_Jquery - Fatal编程技术网

使用ajax内容在JQuery中悬停显示/隐藏div

使用ajax内容在JQuery中悬停显示/隐藏div,jquery,Jquery,我目前有一段代码,当另一个div悬停或关闭时显示/隐藏一个div。 此代码适用于它应用于的第一批数据: $(document).ready(function() { $('.eventViewWrapper').hover( function(){ var eventId = $(this).attr('rel'); $("#eventActions_" + eventId).show(); }, function(){ var e

我目前有一段代码,当另一个div悬停或关闭时显示/隐藏一个div。 此代码适用于它应用于的第一批数据:

$(document).ready(function() {
    $('.eventViewWrapper').hover( function(){
        var eventId = $(this).attr('rel');
        $("#eventActions_" + eventId).show();
   },
   function(){
      var eventId = $(this).attr('rel');
      $("#eventActions_" + eventId).hide();
   });
});
但是,当我通过ajax post获取更多数据时,当我悬停时,div不再显示。 我理解为什么会像以前的ajax功能一样发生这种情况,并且需要实现.live()方法。因此,我做了以下更改:

$(document).ready(function() {
   $('.eventViewWrapper').live('hover', function() {
        var eventId = $(this).attr('rel');
        $("#eventActions_" + eventId).show();
   },
   function(){
      var eventId = $(this).attr('rel');
      $("#eventActions_" + eventId).hide();
   });
});
现在,当我悬停时div出现时,这部分起作用。然而,当我将焦点从div移开时,它并没有隐藏。我想代码的第二部分也需要将.live()方法链接到它,我只是不确定如何链接

谢谢

您可以简单地使用和事件,因为这是内部使用的:

$('.eventViewWrapper').live('mouseenter', function () {
    var eventId = $(this).attr('rel');
    $("#eventActions_" + eventId).show();
}).live('mouseleave', function () {
    var eventId = $(this).attr('rel');
    $("#eventActions_" + eventId).hide();
});
您可以简单地使用和事件,因为这是内部使用的:

$('.eventViewWrapper').live('mouseenter', function () {
    var eventId = $(this).attr('rel');
    $("#eventActions_" + eventId).show();
}).live('mouseleave', function () {
    var eventId = $(this).attr('rel');
    $("#eventActions_" + eventId).hide();
});