jQuery CheckBox单选

一、同级元素app

$(":checkbox").click(function(){
$(this).attr("checked",true);
$(this).siblings().attr("checked",false);
});

获取当前索引值:$(this).index();this

 

 二、不一样级spa

$(':checkbox').each(function(){
                    $(this).click(function(){
                        if($(this).is(':checked')){//或者$(this).attr(':checked')
                            $(':checkbox').removeAttr('checked');
                            $(this).prop('checked',true);
                            //$(this).attr('checked','checked');                        
                        }
                    });
                })

 获取当前索引值:$(this).index(':checkbox');code

 

PS:angularJs中使用jQueryblog

 setTimeout(function () {
            $scope.$apply(function () {

                  //所进行的修改值或样式的代码
            });
        }, 1000);
相关文章
相关标签/搜索