2013-12-22 36 views

回答

1

在javascript中

可以使用document.querySelectorAll("input[type='checkbox']")[0]对于第二个的第一个和document.querySelectorAll("input[type='checkbox']")[1]

进行检查,所有你需要使用document.querySelectorAll("input[type='checkbox']")

换句话说:

First_checkbox = document.querySelectorAll("input[type='checkbox']")[0]; 
Second_checkbox = document.querySelectorAll("input[type='checkbox']")[1]; 

有些事情,你可以用document.querySelectorAll("input[type='checkbox']")标签做:

document.querySelectorAll("input[type='checkbox']")[1].checked = true; 
document.querySelectorAll("input[type='checkbox']")[1].checked = false; 

在jQuery中

第一个可以使用$(":checkbox")[0],第二个可以使用$(":checkbox")[1]

进行检查,所有你需要使用$(":checkbox")

换句话说:

First_checkbox = $(":checkbox")[0]; 
Second_checkbox = $(":checkbox")[1]; 

有些事情,你可以用$(":checkbox")标签做:

$(":checkbox")[1].checked = true; 
$(":checkbox")[1].checked = false; 
相关问题