views:

32

answers:

2

I want to replace a form element with a div and keep the inner html of the form inside the inserted div element. i tried jquery it gives me unkown html element as selection result,

below is the target form and inner html:

<form name="Contents2_frmLogin" action="/SiteManagement/SiteWizard.aspx" method="post"><table border="0"><tr><td></td></tr></table>
</form>

stackoverflow not allow html code. it is just a form element with a table inside and some input elements

thank you .

A: 

Give this a try:

var newDiv = $("<div></div>");
$(newDiv).html( $("#Contents2_frmLogin").html() );
$("#Contents2_frmLogin").replaceWith( newDiv );
Justin Ethier
A: 

Similar one line approach:

$("#Contents2_frmLogin").replaceWith("<div>" + $("#Contents2_frmLogin").html() + "</div>");

enduro