87,994
社区成员
发帖
与我相关
我的任务
分享
<input type="checkbox" name="chk" value="0"/>1
<input type="checkbox" name="chk" value="1"/>2
<input type="checkbox" name="chk" value="2"/>3
<input type="checkbox" name="chk" value="3"/>4
<input type="checkbox" name="chk" value="4"/>5
<input type="checkbox" name="chk" value="5"/>6
<input type="checkbox" name="chk" value="6"/>7
<script type="text/javascript">
<!--
var arr = [];
(function(){
var ochk = document.getElementsByName('chk');
for(var i = 0, len = ochk.length; i < len; i++){
ochk[i].onclick = function(){
if(this.checked){
if(arr.length >= 2){
ochk[arr[1]].checked = false;
arr[1] = this.value;
}else{
arr.push(this.value);
}
}else{
arr.shift();
}
}
}
})();
//-->
</script>