input 单选按钮radio 取消选中

input单选按钮: 在radio按钮中添加属性tag  0代表未被选中

<input name="rdo1" value="AA" type="radio" tag="0" />A
        <br />
        <input name="rdo2" value="BB" type="radio" tag="0" />B
        <br />
        <input name="rdo3" value="CC" type="radio" tag="0" />C

jquery:

$(":radio").click(function () {
                var r = $(this).attr("name");
                $(":radio[name=" + r + "]:not(:checked)").attr("tag", 0);
                if ($(this).attr("tag") == 1) {
                    $(this).attr("checked", false);
                    $(this).attr("tag", 0);
                }
                else {
                    $(this).attr("tag",1);
                }
            });

posted @ 2012-07-30 16:35  不爱吃糖  阅读(10222)  评论(0编辑  收藏  举报