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 #div_element itself?

  • Using RegExp to dynamically create a Regular Expression, and filter content
  • Using jQuery how can we remove disabled attribute from all elements whose value is false?
  • How to move all HTML element children to another parent using JavaScript?
  • jQuery event handler organisation
  • jQuery empty() vs text('')
  • Is there a way to get innerText of only the top element (and ignore the child element's innerText)?

  • 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.

  • Building a web crawler - using Webkit packages
  • jQuery using .toggle() to toggle a single element
  • clear all divs' contents inside a div
  • With jQuery, how can I use the “live” method to alert when a new element is added?
  • How can I highlight a selected list item with jquery?
  • How to remove text between two elements with jQuery
  • 2 Solutions collect form web for “Manipulating jQuery object without changing the html element”

    Use clone to create a copy of the element.

    var el = $('#div').clone();
    

    You can use like

    $().popup($("#div :not(:first-child)"));