Manipulating jQuery object without changing the html element
I have a variable with a jQuery object, for example:
var div = $('#div_element');
How can I manipulate ONLY the
div variable, without changing the
I want to do some edits on the
div variable and to pass it as an argument to a plugin, like this:
var el = $('#div'); el.find(':first').remove(); $().popup(el); //I wrote this plugin myself
Actually I want to display popup containing the
#div element (with removed the first “child”), but don’t want to change the
#div element itself.
2 Solutions collect form web for “Manipulating jQuery object without changing the html element”
clone to create a copy of the element.
var el = $('#div').clone();
You can use like