Javascript jquery选择表内的div
在ajax回调中,当窗体位于表外时,在调用窗体内选择div效果良好,而在表内则不起作用。有什么办法可以让这一切顺利吗 请查看此JSFIDLE:Javascript jquery选择表内的div,javascript,jquery,ajax,Javascript,Jquery,Ajax,在ajax回调中,当窗体位于表外时,在调用窗体内选择div效果良好,而在表内则不起作用。有什么办法可以让这一切顺利吗 请查看此JSFIDLE: 谢谢你的评论 我需要将表单放在td中,并在表单中嵌套一张表 更新 对勾 x 您的HTML无效。TR的唯一子元素是TD或TH。问题是因为HTML无效-表单不能是表的直接后代。这也是。是时候对HTML规范…或表格(它包含..)进行一些更新了。此标记完全扭曲了!必须是table>tr>td>form,而不是table>form或form>trok,明白。更
谢谢你的评论 我需要将表单放在td中,并在表单中嵌套一张表
更新
对勾
x
您的HTML无效。TR的唯一子元素是TD或TH。问题是因为HTML无效-表单
不能是表
的直接后代。这也是。是时候对HTML规范…或表格(它包含
..)进行一些更新了。此标记完全扭曲了!必须是table>tr>td>form
,而不是table>form
或form>tr
ok,明白。更新的JS小提琴:仍然不起作用。
<form method="POST" action="#" class="fileform">
<tr>
<td class="vert-align"><input type="text" name="name" id="name" /></td>
<td class="vert-align"><button class="btn btn-primary btn-xs" type="submit">Update</button>
<div class="feedback-icons">
<span class="file-success">checkmark</span>
<span class="file-error">x</span>
</div>
</td>
</tr>
</form>
<form method="POST" action="#" class="fileform">
<tr>
<td class="vert-align"><input type="text" name="name" id="name" /></td>
<td class="vert-align"><button class="btn btn-primary btn-xs" type="submit">Update</button>
<div class="feedback-icons">
<span class="file-success">checkmark</span>
<span class="file-error">x</span>
</div>
</td>
</tr>
</form>
<h3>Table:</h3>
<table>
<form method="POST" action="#" class="fileform">
<tr>
<td class="vert-align"><input type="text" name="name" id="name" /></td>
<td class="vert-align"><button class="btn btn-primary btn-xs" type="submit">Update</button>
<div class="feedback-icons">
<span class="file-success">checkmark</span>
<span class="file-error">x</span>
</div>
</td>
</tr>
</form>
<form method="POST" action="#" class="fileform">
<tr>
<td class="vert-align"><input type="text" name="name" id="name" /></td>
<td class="vert-align"><button class="btn btn-primary btn-xs" type="submit">Update</button>
<div class="feedback-icons">
<span class="file-success">checkmark</span>
<span class="file-error">x</span>
</div>
</td>
</tr>
</form>
</table>
$(".fileform").submit(function(e)
{
var postData = $(this).serializeArray();
var formURL = $(this).attr("action");
var self = $(this);
$.ajax(
{
url : formURL,
type: "POST",
data : postData,
context: e.target,
success:function(data, textStatus, jqXHR)
{
self.find('.file-success').fadeIn(500);
},
error: function(jqXHR, textStatus, errorThrown)
{
self.find('.file-error').fadeIn(500);
}
});
e.preventDefault();
});
<table>
<tr>
<td class="vert-align">
<form method="POST" action="#" class="fileform">
<table>
<tr>
<td class="vert-align">
<input type="text" name="name" id="name" />
</td>
<td class="vert-align">
<button class="btn btn-primary btn-xs" type="submit">Update</button>
<div class="feedback-icons">
<span class="file-success">checkmark</span>
<span class="file-error">x</span>
</div>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>