2011-10-03 68 views
0

所以我有jquery的代码在这里:jQuery脚本

$(document).ready(function(){ 
    $("div.post.photo").hover(function() { 
     $(this).children("div.show").slideToggle("fast"); 
    }); 
}); 

在这里影响的HTML代码:

<div class="post photo"> 
    <img src="source" /> 
    <div class="show"> 
     <div class="caption"> 
     Caption 
     </div> 
    </div> 
</div> 

但是当你向下滚动页面,更多div的通过另一个脚本(不是我写的)获取,但上面的jQuery脚本不会影响它们。

想法?

回答

2

你需要使用jQuery的.live()处理程序 - “附加的处理程序,为当前选择,现在和将来匹配所有元素的事件” http://api.jquery.com/live/

例如。

$("div.post.photo").live('hover', function() { 
    $(this).children("div.show").slideToggle("fast"); 
}); 
+0

甜。感谢一群伙计。 – Ando