我在上传文件的按钮上有一个点击处理程序。它根据预定义的值检查表格第一列的每个单元格的内容,并且仅在用户确认后继续。我可以让下面的工作,但感觉不优雅。有什么建议么?
$('#upload').click(function() {
var proceed;
$('#mytable tr td:first-child').each(function(a, b) {
if ($(b).html() == 'x') {
proceed = confirm('u sure?');
return false;
}
});
return proceed;
});
编辑:
我想做类似以下的事情我只是不知道正确的语法(这不起作用):
$('#upload').click(function() {
return $('#mytable tr td:first-child').each(function(a, b) {
if ($(b).html() == 'x') {
return confirm('u sure?');
}
});
});