How can I remove an element that is NOT on the DOM using jQuery?

Viewed 96

I want to use jQuery to manipulate a cloned element that is not on the DOM, to perform actions like .remove() on it. Say I have the following code:

var div= $('<div> <div id="div1"></div> </div>');
div.remove('#div1');
console.log(div.html());

The result on the console will still show that the element was not removed. string manipulation is not desirable, I'm looking for something analogue to $().remove()

2 Answers
Related