I have some common elements that are in a #footer and #header divs respectively.
In order to make the selectors faster, I’d like to make a custom jquery object.
A combination of #footer and #header. Something like:
var someCustomContext = $("#footer") + $("#header");
var betterQuickerSelector = $(".buttonClass", someCustomContext);
Is this possible?
Thanks SO!
You can combine selectors with commas:
Or if you have already got two separate jQuery objects you can combine them with the
.add()method:.add()also works with selectors:…and some other options as described on the doco page.