For JavaScript arrays, you use push()
.
(对于JavaScript数组,使用push()
。)
var a = [];
a.push(12);
a.push(32);
For jQuery objects, there's add()
.
(对于jQuery对象,有add()
。)
$('div.test').add('p.blue');
Note that while push()
modifies the original array in-place, add()
returns a new jQuery object, it does not modify the original one.
(请注意,虽然push()
就地修改了原始数组,但add()
返回一个新的jQuery对象,它不会修改原始数组。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…