怎样JAVAscript 中判断一个复选框是否已经选定
function checkbox(){
var tr=document.getElementById("td");
.
.if()
}
<table><tr id="td" >
<td><input type="ckeckbox"></td>
<tr>
<input type="button" onclick="checkbox();">
</table>
那一部分怎么写 能不能 不用 chcked="checked"
function checkbox(){
var tr=document.getElementById("td");
.
.if()
}
<table><tr id="td" >
<td><input type="ckeckbox"></td>
<tr>
<input type="button" onclick="checkbox();">
</table>
那一部分怎么写 能不能 不用 chcked="checked"
function checkbox(){
var chk=document.getElementById("td").getElementsByTagName('input')[0];
if (chk.checked == true) alert('YES');
else alert('NO');
}
</script>
<table>
<tr id="td">
<td><input type="checkbox" name="chk" /></td>
<tr>
</table>
<input type="button" onclick="checkbox();" value="点我" />
++++js checked 的值就是 true or false
而不是checked的值,选中是checked没选中是""
if($(this).is(":checked"))
...
or if($(this).get(0).checked)