代码语言:javascript复制
<input name="demand" type="checkbox" value="222" />
//获取所有name为demand的对象
var obj = document.getElementsByName('demand');
var demand = '';
for (var i = 0; i < obj.length; i ) {
if (obj[i].checked) {
demand = obj[i].value ',';//如果选中,将value添加到变量s中
}
}
alert(demand);