radio中最佳解决方案

radio中最佳解决方案

1、html中

              <td>
                      <input id="status" name="status" type="radio" value="1" checked="checked" onclick="qy()"/>
                      <span>启用</span>
                      <input id="status" name="status" type="radio" value="0"  onclick="jy()"/>
                       <span>禁用</span>
               </td>

2、js中

    function qy(){
        $("input[name='status']").eq(0).attr("checked","checked");
        $("input[name='status']").eq(1).removeAttr("checked");
        $('input[name="status"]:eq(0)').attr("value", 1);
        return;
    };
    function jy(){
        $("input[name='status']").eq(0).removeAttr("checked");
        $("input[name='status']").eq(1).attr("checked","checked");
        $('input[name="status"]:eq(1)').attr("value", 0);
        return;
    };

 

posted @ 2017-05-29 23:44  vimx86  阅读(219)  评论(0编辑  收藏  举报