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);
                }
            });

Nobody gets to write your destiny but you.
原文地址:https://www.cnblogs.com/loveAnimal/p/2615520.html