什么似乎混淆这个线程是之间的区别:
$('.selector').append("");
它将目标元素追加为.selector的子级。
和
$("").appendTo('.selector');
它将目标元素追加为.selector的子级。
注意目标元素& .selector在使用不同方法时改变。
你想做什么是这样的:
$(function() {
// append input control at start of form
$("")
.attr("id","myfieldid")
.attr("name","myfieldid")
.prependTo("#form-0");
// OR
// append input control at end of form
$("")
.attr("id","myfieldid")
.appendTo("#form-0");
// OR
// see .after() or .before() in the api.jquery.com library
});