如何走到这一步的工作原理:如何使用appendTo添加对象但不附加在jQuery中?
var items = [];
$.each([1,2,3,4], function() {
items.push($('<li />').html('test' + this));
});
// clearing/appending as two seperate calls
$('ul').empty();
$(items).appendTo('ul');
但是这不?
var items = [];
$.each([1,2,3,4], function() {
items.push($('<li />').html('test' + this));
});
// clearing/appending in one fluent call
$('ul').empty().append($(items));
这种方式引发以下错误:
No such interface supported.
对我来说这两个例子都工作,火狐:3.0.10的jQuery:1.2.3,究竟是什么抛出错误? – duckyflip 2009-05-21 23:05:28
后者在Firefox 3.0.10上使用jQuery 1.3失败了,但第一次运行。 – jacobangel 2009-05-21 23:56:43