【问题标题】:Unwrap a form tag [duplicate]打开表单标签[重复]
【发布时间】:2011-11-17 21:29:17
【问题描述】:

可能重复:
Clone a <form></form> tag and wrap it around existing content?

这是 Firebug 的主要 HTML 结构。我没有包含任何内部内容或任何内容,因为内容太多。我问了一个类似的问题,但它没有用。我希望我能让以下工作。我需要“解开”您看到的 FORM 标记,但保留其中的任何内容。然后我需要使用相同的 FORM 标签并使其环绕在 正下方的表格。

<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>

【问题讨论】:

  • 对不起,我迷路了....打开一个表单标签!??!?!?!
  • 有一个
    LOTS OF CONTENT
    标签。我需要将
    标签移到其他地方..
  • 一个&lt;form&gt;标签没有显示在屏幕上-它实际上是一个包含表单元素的包装器(例如inputtextarea等)-你能画一张图片或解释你想要的吗页面布局?表单标签可以在页面的任何位置

标签: jquery html forms


【解决方案1】:

我想这段代码会为你完成这项工作。可能会优化,我只是实现了解决方案,优化留给你。

    // 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();

【讨论】:

    猜你喜欢
    • 2011-12-21
    • 1970-01-01
    • 2011-07-13
    • 2022-11-18
    • 1970-01-01
    • 2019-08-11
    • 2018-05-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多