2012-07-21 75 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