打开表单标签 [英] Unwrap a form tag
问题描述
可能存在重复:
克隆< form>< / form>标记并将其包装到现有内容中?
这是主要的HTML结构萤火虫。我没有包含任何内容或任何内容,因为它有很多。我问了一个类似的问题,但没有奏效。我希望我能得到以下工作。我需要解开你看到的FORM标签,但是保留它里面的任何内容。然后,我需要采用相同的FORM标签,并使其环绕在< DIV ID =TOP_NAV>。
This is the main HTML structure from Firebug. I didn't include any inside content or anything because there is to much. I asked a previous question similar but it didn't work. I am hoping I can get the following to work. I need to "unwrap" the FORM tag that you see but keep whatever content is inside it where it is. Then I need to take that same FORM tag and make it wrap around the table right underneath the < DIV ID="TOP_NAV">.
<div id="content">
<div id="top_nav">
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td id="nav_menu" class="bgcolor2 colors_background2 colors_background2_text" valign="top">
<td id="main_content" valign="top">
<script type="text/javascript">
<div id="content_area">
<script type="text/javascript">
<script src="/a/j/product_details.js" type="text/javascript">
<script src="/a/j/product_details.js" type="text/javascript">
<script type="text/javascript">
<form id="vCSS_mainform" onsubmit="javascript:return QtyEnabledAddToCart_SuppressFormIE();" action="/ProductDetails.asp?ProductCode=40124" name="MainForm" method="post">
<span class="PageText_L493n"></span>
<br>
</div>
</td>
</tr>
</tbody>
</table>
</div>
推荐答案
我想这段代码会为您完成工作。这可能是优化的,我只是实现了解决方案,我将离开优化给你。
I guess this code will do the work for you. It may be optimized, I just implemented the solution and I'll leave the optimization to you.
// create a clone of the form element
var cloneForm = $("#vCSS_mainform").clone();
// move the contents of the form to the outside div
$("#content_area").html(cloneForm.html());
// replace the contents of the form with the contents of top_nav div
cloneForm.hide().html($("#top_nav").html());
// set the top_nav div to contain the form and form's contents
$("#top_nav").html(cloneForm);
// show the form
cloneForm.show();
这篇关于打开表单标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!