Skip to content Skip to sidebar Skip to footer

Clone A
Tag And Wrap It Around Existing Content?

So There is an existing form tag as such:
).clone().empty().attr('id', 'newId'); $('#vCSS_mainform').remove(); // only if you don't need it anymore. $('#yourTable').wrap($clone);

note: if you remove the original form, you don't need to set a new id for the clone (no need of .attr('id', 'newId'))


Solution 2:

This is relatively easy to achieve, really all you have to do, is use .clone(), .append() and .empty():

$('#vCSS_mainform').clone().appendTo($('body')).empty();

JS Fiddle demo.

Bear in mind, of course, that duplicate ids are invalid HTML.


Edited to complete the answer, to wrap the #accBox you could use:
$('#accBox').wrap($('#vCSS_mainform').clone().appendTo($('body')).empty());

JS Fiddle demo.

References:


Solution 3:

$("#accBox").wrap($('#vCSS_mainform').clone().empty());

Fiddle demo


Solution 4:

Try someting like this.

function strip(htmlfullstring)
{
   var tmp = document.createElement("formid");
   tmp.innerHTML = html;
   return <form> + tmp.textContent||tmp.innerText+</form>;
}

if i understood your requirement.


Post a Comment for "Clone A Tag And Wrap It Around Existing Content?"