how to replace form element with div and keep the inner html in jQuery or asp.net javascript lib?
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 i开发者_如何学运维nside and some input elements.
Give this a try:
var newDiv = $("<div></div>");
$(newDiv).html( $("#Contents2_frmLogin").html() );
$("#Contents2_frmLogin").replaceWith( newDiv );
Similar one line approach:
$("#Contents2_frmLogin").replaceWith("<div>" + $("#Contents2_frmLogin").html() + "</div>");
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')
精彩评论