Reputation: 277
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 unknown html element as selection result.
This is the target form with inner HTML:
<form name="Contents2_frmLogin" action="/SiteManagement/SiteWizard.aspx" method="post">
<table border="0"><tr><td></td></tr></table>
</form>
It is just a form element with a table inside and some input elements.
Upvotes: 2
Views: 3268
Reputation: 529
i think you have html page you are trying to convert it to asp.net web form , so it must contain only 1 form tag. in this case for your old form(s) element(s) you have to give them id(s) and instead of accessing element(s) through : document.formName.elementName you should access them using : document.getElementById('elementId')
Upvotes: 0
Reputation: 1039
Similar one line approach:
$("#Contents2_frmLogin").replaceWith("<div>" + $("#Contents2_frmLogin").html() + "</div>");
Upvotes: 1
Reputation: 134167
Give this a try:
var newDiv = $("<div></div>");
$(newDiv).html( $("#Contents2_frmLogin").html() );
$("#Contents2_frmLogin").replaceWith( newDiv );
Upvotes: 3