Javascript 删除前选中复选框
我为每个用户设置了一个复选框,复选框的值是用户id 在单击正确对应的复选框之前禁用delete a.按钮的最佳JavaScript是什么 如果按钮被禁用,我希望能够使用bootstraps disabled=“disabled”Javascript 删除前选中复选框,javascript,jquery,twitter-bootstrap,Javascript,Jquery,Twitter Bootstrap,我为每个用户设置了一个复选框,复选框的值是用户id 在单击正确对应的复选框之前禁用delete a.按钮的最佳JavaScript是什么 如果按钮被禁用,我希望能够使用bootstraps disabled=“disabled” 首先,在首次加载HTML时,应禁用所有删除按钮。您可以将disabled='disabled'属性添加到PHP代码中的每个删除按钮 然后在JavaScript中,在复选框上查找更改事件: $("input[type='checkbox']").change(functi
首先,在首次加载HTML时,应禁用所有删除按钮。您可以将
disabled='disabled'
属性添加到PHP代码中的每个删除按钮
然后在JavaScript中,在复选框上查找更改事件:
$("input[type='checkbox']").change(function() {
var thisRow = $(this).parents("tr");
if(this.checked) {
thisRow.find("a.btn-danger").attr("disabled", false);
} else {
thisRow.find("a.btn-danger").attr("disabled", "disabled");
}
});
$("input[type='checkbox']").change(function() {
var thisRow = $(this).parents("tr");
if(this.checked) {
thisRow.find("a.btn-danger").attr("disabled", false);
} else {
thisRow.find("a.btn-danger").attr("disabled", "disabled");
}
});