The jQuery.wrapAll function takes a dom subtree and wraps it around a jQuery object. I want to do that but without aquiring the target jQuery object via selector: I have a bunch of references to jQuery wrapped DOM elements and I want to apply wrapAll to all of them. Is it possible to do it without assigning a common class and selecting them through the class?
How can I group jQuery objects without using selectors?
What's the problem? If you have the references, can't you just call myJqueryRef.wrapAll(...)? –
Mccourt
i have many references, not one reference. I want to combine them –
Depurative
You can add elements to a jQuery object using the add
function. add
accepts a selector (adds matching elements), a raw DOM element (adds it), an HTML fragment (creates the element(s) and adds them), and a jQuery object (adds all of the elements in it). That last probably matches what you're looking for.
Yes, add them all to the same object.
obj1.add(obj2).add(obj3).wrapAll('<div class="contentwrapper" />');
© 2022 - 2024 — McMap. All rights reserved.