简体   繁体   中英

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?


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.

使用clone创建该元素的副本。

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

您可以使用像

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM