这令人厌倦。我正在尝试从一个元素到另一个元素进行简单的追加:
var contentBlob = $('<div></div>', {
"id" : "content-blob",
"css" : {
"display" : "none",
"color" : "red"
}
});
// this guy gets a full xhtml page with head and body.
// I don't want to use load()
model.getHtml(indexUrl, function(response){
if(response != 0){
contentBlob.html(response);
}
});
contentBlob.appendTo('body');
//I've verified the that the contentBlob (#content-blob) is in the body
// This should be super simple. No matter what I do, Its not appending
// the ul.
$('#content-blob > ul').appendTo('#contents-index-actual-index');
我已经检查了选择器,一切看起来都合法。一个有趣的事情是,如果我不将ul添加到选择器,#content-blob会附加。
答案 0 :(得分:0)
Squint是对的。异步get在appendTo之后发生。