html通过jquery追加问题
您好,我正在通过 jquery 将列附加到行。 我有一行看起来像这样
<form action="certifications.php?action=addnew_save" method="post">
<tr id="add_new_<?php echo($v_id);?>" valign="top" bgcolor="#EEEEEE"></tr>
</form>
现在我正在做什么,我将一些 附加到这一行。我的 javascript 函数如下所示
var sr=document.getElementById('hidden_'+vid).value;
var append='';
append+='<td width="40" align="center">'+sr+'</td>';
append+='<input type="hidden" value="'+vid+'">';
append+='<td width="200" align="center"><input type="text" name="short_name" size="25" autocomplete="off" value="" /></td>';
append+='<td width="200" align="center"><input type="text" name="full_name" size="25" autocomplete="off" value="" /></td>';
append+='<td width="80" align="center"></td>';
append+='<td width="80" align="center"><input type="checkbox" name="feature" /></td>';
append+='<td width="80" align="center"><input type="text" name="order" size="2" value="" /></td>';
append+='<td width="80" align="center"><input type="checkbox" name="hidden" /></td>';
append+='<td width="80" align="center"></td>';
append+='<td width="50" class="style3" align="center"></td>';
append+='<td width="50" class="style3" align="center"><INPUT TYPE="submit" VALUE="Submit" NAME="Submit"></td>';
append+='<td width="50" class="style3" align="center"><a href="certifications.php?action=delete&id="onclick="if(confirm(\'Are you sure you want to Delete it ?\')){return true;}else{return false;}" >Delete</a></td>';
append+='<td width="80" align="center"></td>';
jQuery('#add_new_'+vid).append(append);
列已附加,但问题出在 form
标记上。从我的代码中,我希望附加 html 后应该看起来像这样
<form action="certifications.php?action=addnew_save" method="post">
<tr id="add_new_<?php echo($v_id);?>" valign="top" bgcolor="#EEEEEE">
<td widht="40">Value</td>
Other tds
.
.
.
.
</tr>
</form>
,但是我得到了上面的表单标签 ,它看起来像这样
<form action="certifications.php?action=addnew_save" method="post">
</form>
<tr>
my <td>
</tr>
附加时有什么问题?为什么表单标签总是在上面
Hi I am appending columns to a row though jquery.
I have a row which looks like this
<form action="certifications.php?action=addnew_save" method="post">
<tr id="add_new_<?php echo($v_id);?>" valign="top" bgcolor="#EEEEEE"></tr>
</form>
Now What I am doing, I am appending some <td>
to this row. My javascript function looks like this
var sr=document.getElementById('hidden_'+vid).value;
var append='';
append+='<td width="40" align="center">'+sr+'</td>';
append+='<input type="hidden" value="'+vid+'">';
append+='<td width="200" align="center"><input type="text" name="short_name" size="25" autocomplete="off" value="" /></td>';
append+='<td width="200" align="center"><input type="text" name="full_name" size="25" autocomplete="off" value="" /></td>';
append+='<td width="80" align="center"></td>';
append+='<td width="80" align="center"><input type="checkbox" name="feature" /></td>';
append+='<td width="80" align="center"><input type="text" name="order" size="2" value="" /></td>';
append+='<td width="80" align="center"><input type="checkbox" name="hidden" /></td>';
append+='<td width="80" align="center"></td>';
append+='<td width="50" class="style3" align="center"></td>';
append+='<td width="50" class="style3" align="center"><INPUT TYPE="submit" VALUE="Submit" NAME="Submit"></td>';
append+='<td width="50" class="style3" align="center"><a href="certifications.php?action=delete&id="onclick="if(confirm(\'Are you sure you want to Delete it ?\')){return true;}else{return false;}" >Delete</a></td>';
append+='<td width="80" align="center"></td>';
jQuery('#add_new_'+vid).append(append);
The columns are appended but the problem is of form
tag. From my code I want the after appending the html should look like this
<form action="certifications.php?action=addnew_save" method="post">
<tr id="add_new_<?php echo($v_id);?>" valign="top" bgcolor="#EEEEEE">
<td widht="40">Value</td>
Other tds
.
.
.
.
</tr>
</form>
But I am getting the form tag above <tr>
and it looks like this
<form action="certifications.php?action=addnew_save" method="post">
</form>
<tr>
my <td>
</tr>
What is the problem in appending? Why form tag is always above
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更改
为
您不想在该元素之后添加代码,但您试图将其插入到 tr 中。
更新:从技术上讲,您不应该用
Change
to
You don't want to add your code after the element, but you are trying to insert it into the tr.
UPDATE: Technically you should not be wrapping a
<tr>
with a<form>
, its invalid HTML. A tr must be a child of a table, or tbody, and tr elements must have td as children. You'll either need a form in each td, or you'll need your form to wrap the entire table.