Is there some jquery magic that will let me do the following:
[0- define some element in HTML (eg, a unchecked checkbox)]
1- update its DOM element by s
You may use the clone method:
var els = $('.els'), saved = els.clone (true);
els.remove ();
// .... do other stuff
saved.appendTo ($('.wherever-you-want-to'));
That said, though, it's better to show & hide them (via display: none
, for example), than to manipulate the DOM as it's very expensive. If you have to, use DOM insertion & removal (as above), rather than .html ()
, which recreated a node from the given string every time.