jquery让checkbox只能选中一个怎么实现 我现在有一个DIV ID是list 这个ID下面有很多checkbox我只想让他只选中一个,因为BOSS不让用radio 请问我怎么在单击checkbox只选中一个, 然后点击删除按钮时获取当前这个选中的checkbox value值. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //控件复选框只能选择一项 jQuery(document).ready(function() { jQuery("#list input[type='checkbox']").click(function() { if (jQuery(this).attr("checked") == true) { jQuery("#list input[type='checkbox']").attr("checked", false); jQuery(this).attr("checked", true); } }); }); 那么点击按钮时怎么获取当前checkbox选中的value值 遍历一下 "checked" == true 就取值 jquery中有一个这样的方法叫“siblings”表示其他的和自己是同类的,你把自己设置成true,其他的就用这个函数来设置成false就可以了 那我取这个选中的CHECKBOX值怎么取呀, 怎么遍历 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <title>checkBox4radio.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(function () { var allBox = $(":checkbox"); allBox.click(function () { allBox.removeAttr("checked"); $(this).attr("checked", "checked"); }); $(":button").click(function () { alert($(":checkbox:checked").val()); }); }); </script> </head> <body> <input type="button" value="remove" /> <div> <input type="checkbox" value="1"/> <input type="checkbox" value="2"/> <input type="checkbox" value="3"/> <input type="checkbox" value="4"/> </div> </body></html> js函数问题,老是执行错误 选项列表库功能说明 求一JS菜单 服务器端图片判断 未何不见了 用javascript来检查连接速度?? event.clientX(clientY)的返回值? window.open()只能打开一个新窗口,那要是一个链接需要target="_main",有办法实现吗? 我做了一个输入界面,旁边有一个查看按钮。。。。。。。看看这种功能如何实现? 关于时间相减的小问题 帮忙看下批量设置,咋我一设置就好像刷新页面了的。 看到有人用jquery把radio单选框的原型变成方的?
jQuery(document).ready(function() {
jQuery("#list input[type='checkbox']").click(function() {
if (jQuery(this).attr("checked") == true) {
jQuery("#list input[type='checkbox']").attr("checked", false);
jQuery(this).attr("checked", true);
}
});
});
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>checkBox4radio.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(function () {
var allBox = $(":checkbox");
allBox.click(function () {
allBox.removeAttr("checked");
$(this).attr("checked", "checked");
});
$(":button").click(function () {
alert($(":checkbox:checked").val());
});
});
</script> </head>
<body>
<input type="button" value="remove" />
<div>
<input type="checkbox" value="1"/>
<input type="checkbox" value="2"/>
<input type="checkbox" value="3"/>
<input type="checkbox" value="4"/>
</div>
</body>
</html>