如何走到這一步的工作原理:如何使用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