怎么让这三个checkbox只能选择一个,当选择一个的时候其他选择的就取消<input type ="checkbox" id="CheckBox1" runat="server" />
<input type ="checkbox" id="CheckBox2" runat="server" />
<input type ="checkbox" id="CheckBox3" runat="server" />
<input type ="checkbox" id="CheckBox2" runat="server" />
<input type ="checkbox" id="CheckBox3" runat="server" />
解决方案 »
- JAVASCRIPT/JQUERY:如何捕捉这样NB的事件??
- JavaScript无法在浏览器上正常显示(由于毕业设计,非常急)
- 发现JSON一种新的功能!!!
- JS操作数组
- 控制单选按钮的js问题,判断表单里的单选按钮的值,如果跟数组里的相等就选中
- 有没有人见过这种javascript的写法
- 快帮忙啊,要死人了!!
- 如何激发关于 document 的事件,通过直接点击页面而不是点按钮或其它什么的来实现
- 用window.setInterval设置时间间隔执行指定的代码后如何使其停止?
- 用VBScript制作网站搜索 -- 如何变为 JavaScript?
- jquery的validate插件,提交表单后,可不可以让不符合规则的第一个input获得焦点
- 几行ie下不兼容的代码,求大哥大姐指点...
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$(".checkbox").change(function(){
if($(this).is(":checked")){
$(this).siblings().attr("checked",false);
}
})
});
</script>
</head>
<body>
<div id="main">
<input type ="checkbox" class="checkbox" id="CheckBox1" runat="server" />
<input type ="checkbox" class="checkbox" id="CheckBox2" runat="server" />
<input type ="checkbox" class="checkbox" id="CheckBox3" runat="server" />
</div>
</body>
</html>jquery,不过你直接拷到你的页面就可以用
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<div id="main">
<input type ="checkbox" class="checkbox" id="CheckBox1" runat="server" onclick="document.getElementById('CheckBox2').checked=false;document.getElementById('CheckBox3').checked=false;"/>
<input type ="checkbox" class="checkbox" id="CheckBox2" runat="server" onclick="document.getElementById('CheckBox1').checked=false;document.getElementById('CheckBox3').checked=false;"/>
<input type ="checkbox" class="checkbox" id="CheckBox3" runat="server" onclick="document.getElementById('CheckBox1').checked=false;document.getElementById('CheckBox2').checked=false;"/>
</div>
</body>
</html>