radio取消选中并能再次选中

网上很多都是只能取消选中,之后就无法选中了。
按照这个方法可以再次选中

$(document).ready(function(){
        var old = null; //用来保存原来的对象
        $(".radioCheck").each(function(){//循环绑定事件
            if(this.checked){
                old = this; //如果当前对象选中,保存该对象
            }
            this.onclick = function(){
                if(this == old){//如果点击的对象原来是选中的,取消选中
                    this.checked = false;
                    old = null;
                } else{
                    old = this;
                }
            }
        });
    });

转载自 http://iswift.iteye.com/blog/1736015

猜你喜欢

转载自blog.csdn.net/tutian2000/article/details/80256757