- 求解 value="true" 的checkbox為什麼不能選中
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js">
</head>
<body>
<div id="tabsList-3">
<input id = "1" type="checkbox" value="true" />
<input id = "2" type="checkbox" value="false" />
<input id = "3" type="checkbox" value="false" />
<input id = "4" type="checkbox" value="false" />
<input id = "5" type="checkbox" value="false" />
<input id = "6" type="checkbox" value="false" />
<input id = "7" type="checkbox" value="false" />
<input id = "8" type="checkbox" value="false" />
<input id = "9" type="checkbox" value="false" />
</div>
</body>
<script>
$(document).ready(function(){
$("#tabsList-3 input[type='checkbox']").each(function(){if ($(this).value ==
"true") {
$(this).attr("checked", true);}})
});
</script>
</html>
最佳回答:
if ($(this).value == "true"
改成
if (this.value == "true"