html - How to use jQuery to retrieve a copy of the DOM to modify in memory only -


is possible use jquery grab specific part of dom variable jquery object upon can perform action(s) without affecting dom itself. when don't want affect dom, not want changes visible user, cannot hidden via css.

the scenario follows. want grab specifc div's contents, make few changes it, surround content in tag , post server via ajax generate pdf document.

right grabbing div need via:

var maindiv = $(sourceselector + " div").filter(function (index, element) { if ($(this).hasclass("abc_page") && $(this).is(":visible")) return true; }); 

problem if this:

$maindiv.find("#myotherdiv").append("<span>new content</span>"); 

i see changes on page, when want them in in memory copy. based on jquery documentation thought filter() create new object , not reflect changes web page.

thanks

you should using .clone() make copy. can modify them before inserting document (or not in case).

http://api.jquery.com/clone/


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -