[ACCEPTED]-How to combine two jQuery results-jquery
Accepted answer
You can use add();
var $foos = $('.foo');
var $foosAndBars = $foos.add('.bar');
or
var $allFoosAndBars = $allFoos.add($allBars);
0
Another solution is to use jQuery.merge() (jQuery > 1.0)
Description: Merge 3 the contents of two arrays together into 2 the first array.
So you could simply use 1 it to merge both result :
var $allFoos = $('.foo');
var $allBars = $('.bar');
var $allFoosAndBars = $.merge($allFoos, $allBars);
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.