關於Chrome CheckBox第二次選擇無效,chromecheckbox

來源:互聯網
上載者:User

關於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>
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.