2012-07-21 71 views
-1

在下面的代碼,而試圖改變動態geneted div的內部HTML,內HTML dosent變化。Jquery的:添加內部HTML動態生成的div

$.ajax({ 
    url: 'xxx.xxx', 
    beforeSend: function() { 
     $('#scroll_items').append('<div class="list_item more_content" align="center"><img src="loader.gif"></div>'); 
    }, 
    success: function(data) {  
     $('#scroll_items div:last').html("hai to all");  
    } 
}); 

HTML部分

<div id="scroll_items"> 
    <div class="list_item1"> 
    Scroll beyond this container to automatically load more content 
    </div> 
    <div class="list_item"> 
    [ List Item 2 ] 
    </div> 
    </div> 
</div> 
+0

,你能否告訴我們在html? – Adil 2012-07-21 18:49:56

+4

你是否確定成功功能甚至解僱? – prodigitalson 2012-07-21 18:50:25

+0

我不認爲成功功能的發射。 – Shreedhar 2012-07-21 18:51:44

回答

1

只是刪除一個額外的大括號,它可能工作。

$.ajax({ 
     url: 'xxx.xxx', 
     beforeSend: function() { 
     $('#scroll_items').append('<div class="list_item more_content" align="center"><img src="loader.gif"></div>'); 
     }, 
     success: function(data) { 
     $('#scroll_items div:last').html("hai to all"); 
     } 
    }); 

試試這個。

,或者嘗試

success: function(data) { 
setTimeout(function(){ 
     $('#scroll_items div:last').html("hai to all"); 
     },100); 
    } 
+0

是花括號CME通過錯誤,對不起, – pckabeer 2012-07-21 18:58:13

+0

@pckabeer即使在刪除該大括號後仍無法正常工作? – Shreedhar 2012-07-21 18:59:31

+0

那個大括號是我在這裏輸入時發生的一個錯誤 – pckabeer 2012-07-21 19:01:56