我有一个表,其中一个复选框已在页面加载时选中。我要那个答辩人不能改变那一拳。因此,我正在尝试,如果有人单击该复选框,该复选框将再次自动选中,但这段代码不起作用。下面是我的密码。
$(document).ready(function(){
$('tr td').each(function(){
$(this).find('input[type="checkbox"]:checked').change(function(){
$(this).find('input[type="checkbox"]').prop('checked',true);
});
});
});发布于 2014-08-29 12:10:35
也许完全按照其他人的建议和disable来做。或者,如果希望代码工作,则在第二部分中使用错误的选择器,因为this引用了由前一个选择器选择的复选框。
$(document).ready(function(){
$('tr td').each(function(){
$(this).find('input[type="checkbox"]:checked').change(function(){
$(this).prop('checked',true); // <-- Here `this` means the checkbox already.
});
});
});https://stackoverflow.com/questions/25567962
复制相似问题