insertAfter multiple elements in jQuery -
var group1 = $('#coach-group-group1'); var group2title = $('#title-group2').clone(); group2title.remove(); var group2 = $('#coach-group-group2').clone(); group2.remove(); $(group2, group2title).insertafter(group1);
.. doesn't seem work, inserts first of 2 elements provided, not second, , there no errors in console either.
how insert multiple elements, in order, 1 after other using insertafter
?
$(group2, group2title)
doesn't create set of 2 dom elements. second argument is context in first argument evaluated, if first argument not selector, second argument ignored.
it seems looking .add
:
group2.add(group2title).inserafter(...);
but think intentions clearer if used .after
:
group1.after(group2, group2title);
fwiw, doesn't make sense call .remove
on elements because not in document.
Comments
Post a Comment