我有两个函数。
1
function foo(elems){
elems.each(function(){
});
}
foo($('selector1,selector2')); // calling foo
2
function bar(elem1,elem2){
// some logic
}
bar($('selector1'),$('selector2)); // calling bar
然而,现在我需要在bar()
内使用foo()
。
function bar(elem1,elem2){
foo(?); // I'm stuck here. I want to pass both elem1 and elem2 as single jquery object
}
我尝试过 $(elem1,elem2)
但它只包含了 elem1
。那么我该怎么做,才能将 elem1
和 elem2
作为单个 jQuery 对象传递,以便在 foo()
中通过 .each()
进行迭代呢?
.add()
呢?谢谢,我会尽快接受的 :) - Amit Joki