我有一个动态生成的表格,可以为学生出勤。如果单击行的任何部分,行将扩展有关学生的其他信息。我的问题是,如果点击出勤按钮(红色 x),则该行会扩展,但出勤被标记得很好。
我找到了一种禁用最后一列的方法(通过为最后一列上的所有单元格赋予相同的名称并使用一些 jquery 使其不可点击),但是这样做时按钮也被禁用了。
Javascript/jQuery
$(function () {
//This is the line I used to disable the last column, but is affecting the buttons
$('td[name="attend"]').click(function () {
return false;
});
//the rest of the code is used for expanding each row
$("td[colspan=7]").find("p").hide();
$("table").click(function (event) {
event.stopPropagation();
var $target = $(event.target);
if ($target.closest("td").attr("colspan") > 1) {
$target.slideUp();
} else {
$target.closest("tr").next().find("p").slideToggle();
}
});
});
我已将最后一列中的所有单元格命名为“参加”。任何帮助深表感谢!
根据要求,这里是每个按钮的代码。每个按钮都是它自己的表单,位于每行的最后一个单元格内。 php
echo "<td style=\"min-width:75px;\" name=\"attend\">";
echo "<form method=\"POST\" onSubmit=\"return new_user(this);\" >";
echo "<input type=\"hidden\" value=\"" . $row2['status'] . "\" name=\"astatus\" />";
echo "<input type=\"hidden\" value=\"" . $row2['cancel_key'] . "\" name=\"mark_attend\" />";
echo "<input type=\"image\" src=\"$image\" name=\"pic\" />";
echo "</form>";
echo "</td>";