[英]jquery not working on appended content (after infinite scroll)
我有一個jQuery函數,可在元素循環中的每個元素上顯示隱藏的內容。 這可以完美地工作,但是問題是當我在循環中添加新元素時,它會停止工作。 它實際上適用於某些元素,不適用於其他元素(奇怪的行為)。
<script type="text/javascript">
jQuery(document).ready(function($) {
$(".see_all").click(function(){
if ($(this).next().css('display') == 'none'){
$(this).next().show();
}
else
if($(this).next().is(':visible')){
$(this).next().hide();
}
});
})
</script>
HTML代碼
<div class="center_container">
<%for users in @user%>
<div class="see_all">
<span style="color:#808080;cursor:pointer">See All Reviews(<%=@beep_count= (@beep.opposes.count + @beep.neutrals.count + @beep.supports.count)%>)</span>
</div>
<div style="display:none;" class="hidden">
No reviews available
</div>
<%end%>
</div>
我試圖用這個解決它
$("body").on("click", ".see_all", function() {
if ($(this).next().css('display') == 'none')
{
$(this).next().show();
}
else
if($(this).next().is(':visible'))
{
$(this).next().hide();
}
});
但這沒用。 我在新的jquery解決方案中犯了一個錯誤嗎:(
請幫忙
解決....我發現我的jquery文件存在兼容性問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.