不能移动DOM元素到其他位置

Can't move DOM element to other position

本文关键字:其他 位置 元素 移动 DOM 不能      更新时间:2023-09-26

这太烦人了。我试图做一个简单的追加从一个元素到另一个:

            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将追加

Squint是对的。异步get发生在appendTo之后