Example code:
jQueryElement.append(jQueryOtherElement.remove("#some-selector"))
Will this make a copy of my element and append it or will it actually use the DOM objects?
Basically, I’m wondering if the above code is using innerHTML and if so, is there a way (in jQuery?) to append the DOM nodes after removing them from another location.
It will actually use the DOM objects removed by the
.remove()call – it is not using innerHTML, but rather the actual DOM nodes. There is no need to copy as the previous DOM objects were removed from the DOM and are available to be inserted.If you look at the jQuery 1.7 code, the remove function internally calls:
which just removes the node from the DOM. The nodes are all left in the jQuery object so when you then call append on that jQuery object, they are all still available to be appended directly with any copy or conversion.