-1

以下のコードでは、動的に生成されたdivの内部htmlを変更しようとすると、内部htmlが変更されます。

  $.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>
4

1 に答える 1

1

余分な中括弧を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);
   }
于 2012-07-21T18:56:17.210 に答える