Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 从一个地方复制到另一个地方后无法提交表单_Jquery_Forms - Fatal编程技术网

Jquery 从一个地方复制到另一个地方后无法提交表单

Jquery 从一个地方复制到另一个地方后无法提交表单,jquery,forms,Jquery,Forms,点击按钮后,我将表单从右栏移动到左栏 代码是: $('#left_col').html($('#cart_form').html()); 但我不能提交。我想知道上面的代码是否正确地复制了所有标记,从到 我检查了form元素是否存在,如下所示: if ($('form').length == 0) { alert("no"); } 而且它不会提醒“否”表示它存在。我的表单的标记是 <form action="#" method="POST" id="cart_form"> &

点击按钮后,我将表单从右栏移动到左栏

代码是:

$('#left_col').html($('#cart_form').html());
但我不能提交。我想知道上面的代码是否正确地复制了所有标记,从

我检查了
form
元素是否存在,如下所示:

if ($('form').length == 0) {
   alert("no");
}
而且它不会提醒“否”表示它存在。我的表单的标记是

<form action="#" method="POST" id="cart_form">
<table class='header_tbl' style="background:none !important;">
<thead>
    <tr>
        <th>Item Name</th>
        <th>Unit Price</th>
        <th>Qty</th>
        <th>Amount(RM)</th>
        <th></th>
    </tr>
</thead>
.........................
CONTENT APPENDED BY JQueRY
........................
$(“#yourform”).html()复制表单标记中的内容,而不复制表单标记

试着把你的表格放到一个div中

<div id="divID">
<form action="#" method="POST" id="cart_form">
<table class='header_tbl' style="background:none !important;">
<thead>
    <tr>
        <th>Item Name</th>
        <th>Unit Price</th>
        <th>Qty</th>
        <th>Amount(RM)</th>
        <th></th>
    </tr>
</thead>
</form>
</div>
$(“#yourform”).html()复制表单标记中的内容,而不复制表单标记

试着把你的表格放到一个div中

<div id="divID">
<form action="#" method="POST" id="cart_form">
<table class='header_tbl' style="background:none !important;">
<thead>
    <tr>
        <th>Item Name</th>
        <th>Unit Price</th>
        <th>Qty</th>
        <th>Amount(RM)</th>
        <th></th>
    </tr>
</thead>
</form>
</div>


尝试
$('.'左列').html($('.'购物车表单')[0].outerHTML)

尝试
$('.'左列').html($('.'购物车表单')[0].outerHTML)

以这种方式移动元素可以释放事件处理程序。检查这个问题和答案-他并没有失去他的事件处理程序,因为onclick事件直接用于ButtonGare。他只复制内部html。这就是为什么没有表单标签的原因。他应该获取外部html:$('#cart_form')[0]。检查这个问题和答案-他并没有失去他的事件处理程序,因为onclick事件直接用于ButtonGare。他只复制内部html。这就是为什么没有表单标签的原因。他应该抓取外部html:$(“#购物车表单”)[0]。外部html不会提交,请检查html代码以查看是否复制了标记表单。。我认为当你做$(“#yourform”).html()时,它是在复制表单标记中的内容参见此链接:我猜是一样的..但是我如何检查标记是否存在?如果你在google chrome上,右键单击页面并选择最后一个选项inspect Element不提交仍然尝试检查html代码以查看标记表单是否被复制。。我认为当你做$(“#yourform”).html()它正在复制表单标记中的内容请参见此链接:我猜也是。但是如何检查标记是否存在?如果您在google chrome上,请右键单击页面,然后选择最后一个选项inspect Element不附加到新目标。在将表单移到左侧之前,您确定页面上有该表单吗?你能在移动前运行
if($('cart\u form')。length==0){
检查吗?是的,我有form元素,运行了($('form')。length==0){没有附加到新的目标。你确定在将表单移到左边之前页面上有该表单吗?你能运行
if($('cart\u form')。length==0){
移动前检查?是的,我有表单元素,运行($('form')。长度==0){
<div id="divID">
<form action="#" method="POST" id="cart_form">
<table class='header_tbl' style="background:none !important;">
<thead>
    <tr>
        <th>Item Name</th>
        <th>Unit Price</th>
        <th>Qty</th>
        <th>Amount(RM)</th>
        <th></th>
    </tr>
</thead>
</form>
</div>
$('#left_col').html( $("#divID").html() );