2014-05-14 159 views
0

我试图在加载图像(和一些html周围)与jQuery加载();后图像淡入淡出;我知道我应该使用load()的回调函数;但我不知道如何在回调中定位/链接图像。下面简化代码:加载后加载()后淡入图像()

jQuery的

$(".load-post").click(function(){ 
    var post_link = $(this).attr("href"); 
    $("#image-container").load(post_link,function(l){ 
     $(this).load(function(e){ 
      $(this).fadeIn(1000); //? 
     }); 
    }); 
    return false; 
}); 

集装箱

<div id="image-container"></div> 

加载的内容会

<figure><img src=/images/image.jpg"></figure> 

如何我加载它后 '的方针' 的<img>

+0

做你的意思是:

dbndhjefj

+0

是,由Jason P. – Damien

回答

1

我对这个问题的理解是你想在Ajax加载一些内容之后加载图像。

$(".load-post").click(function(){ 
     var post_link = $(this).attr("href"); 
     $("#image-container").load(post_link,function(l){ 
     //This function is triggered after your content has loaded successfully inside your #image_container. 
     //Suppose you have an image <img id="after_fadein" src="loadme.png" /> 
     //Now simply fade In the image using DOM manipulation. 
     $('#after_fadein').fadeIn(1000); 
      }); 
     }); 
    });` 
+0

固定听起来很简单,但不起作用。 – Damien