我有一张这样的桌子:
<table><tbody id="foo">
<tr id="1"><td>a</td><td>b</td></tr>
<tr id="2"><td>c</td><td>d</td></tr>
<tr id="3"><td>e</td><td>f</td></tr>
</tbody></table>
当我应用 jQuery 操作时:
$('#foo').append($('#1'),$('#2'));
然后我得到以下(预期的)结果:
+-+-+
|e|f|
+-+-+
|a|b|
+-+-+
|c|d|
+-+-+
我想将该append()
函数嵌入另一个函数myAppend()
中,我这样做了:
$.fn.myAppend = function(s){
this.append(s);
// something to be, which is irrelevant to this question
};
$('#foo').myAppend($('#1'),$('#2'));
结果与上面不同,我得到了这个(无意):
+-+-+
|c|d|
+-+-+
|e|f|
+-+-+
|a|b|
+-+-+
为什么结果不一样?我怎样才能myAppend()
以与 相同的方式进行工作append()
?