關於Chrome CheckBox第二次選擇無效,chromecheckbox
兄弟們遇到問題了,CheckBox .attr('checked',false); Chrome和Firefox第二次點擊無效。
然後解決了把attr 改成了 prop
以後操作屬性的時候各位記下,用prop 因為大家用的都是 jQuery 1.6+ 了!
貼部分代碼
$("#selectAllEvent").click(function(){var thisValue = $(this).val();if(thisValue=="0"){$(this).attr("value","1");$("#pageList :checkbox").prop("checked", true); //全選}else{$(this).attr("value","0");$("#pageList :checkbox").prop("checked", false); //取消全選 } });
判斷checkbox選中無效
代碼本身沒有問題,能實現你要的效果
關鍵你要看這些被執行到了沒有,加個斷點調試下
另外指出代碼中的幾個問題,1、(checkbox.checked==true)是bool類型,而checkBox1.Checked也是bool類型,所以不需要寫==true
2、textbox2.enabled也是bool類型,所以可以直接用checkBox1.Checked來對其賦值
實際上你的代碼只需要寫兩句
textBox1.Enabled = checkBox1.Checked;
textBox2.Enabled = !checkBox1.Checked;
在javascript中怎讓checkbox無效
<html>
<head>
<script type="text/javascript">
function disable()
{
document.getElementById("check1").disabled=flase
}
</script>
</head>
<body>
<form>
<input type="checkbox" id="check1" />
<input type="button" onclick="disable()" value="Disable Checkbox" />
</form>
</body>
</html>