我现在有一个DIV ID是list 
这个ID下面有很多checkbox我只想让他只选中一个,因为BOSS不让用radio 
请问我怎么在单击checkbox只选中一个, 然后点击删除按钮时获取当前这个选中的checkbox value值.

解决方案 »

  1.   

     //控件复选框只能选择一项
                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);
                        }
                    });
                });
      

  2.   

    那么点击按钮时怎么获取当前checkbox选中的value值
      

  3.   

    遍历一下 "checked" == true 就取值
      

  4.   

    jquery中有一个这样的方法叫“siblings”表示其他的和自己是同类的,你把自己设置成true,其他的就用这个函数来设置成false就可以了
      

  5.   

    那我取这个选中的CHECKBOX值怎么取呀, 怎么遍历
      

  6.   


    <!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>