克隆&LT;形式为GT;&LT; /表及GT;标签并将其包装围绕现有内容吗? [英] Clone a <form></form> tag and wrap it around existing content?
问题描述
所以现有表单标签这样:
&LT;表ID =vCSS_mainform的onsubmit =JavaScript的:返回QtyEnabledAddToCart_Sup pressFormIE();行动=/?ProductDetails.asp产品code = 40124NAME =MainForm的方法=后&gt;内容和LT的一群; /表及GT;
有就是这种形式的标签里面一堆的内容。我需要的只是它的元素,克隆它,并且将其套在我有页面上的其他表格元素。
我不希望在表单标签东西被克隆。这可能吗?
我不能只是做$(P)wrapAll()。因为这种形式的行动包含内容dymanic改变。所以,我需要找到任何页面的用户是,准确的一个表单标签和克隆。
变量$克隆= $('#vCSS_mainform')。克隆()。空()。ATTR('身份证','NEWID');
$('#vCSS_mainform')删除()。 //只有当你不需要它了。
$('#yourTable')包($克隆)。
请注意:如果删除了原来的形式,你并不需要设置一个新的ID为克隆(无需的.attr('身份证','NEWID')
)
So There is an existing form tag as such:
<form id="vCSS_mainform" onsubmit="javascript:return QtyEnabledAddToCart_SuppressFormIE();" action="/ProductDetails.asp?ProductCode=40124" name="MainForm" method="post">Bunch of Content</form>
There is a bunch of content inside of this form tag. I need to take just the element of it, clone it, and wrap it around another TABLE element that I have on the page.
I don't want anything in the form tag to be cloned. Is this possible?
I can't just do $("p").wrapAll(""); because that form action contains dymanic content that changes. So i need to find the form tag on whatever page the user is on and clone that exact one.
var $clone = $('#vCSS_mainform').clone().empty().attr('id', 'newId');
$('#vCSS_mainform').remove(); // only if you don't need it anymore.
$('#yourTable').wrap($clone);
note: if you remove the original form, you don't need to set a new id for the clone (no need of .attr('id', 'newId')
)
这篇关于克隆&LT;形式为GT;&LT; /表及GT;标签并将其包装围绕现有内容吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!