jquery操作checkbox火狐下第二次无法勾选问题
原来的代码:
$('#checkAll').click(function(){ var current = $(this) $('.checkbox').each(function(){ debugger; if(current.is(':checked')) { $(this).attr('checked', true); } else { $(this).attr('checked', false); } }); })
这样在firefox和chrome浏览器下第二次勾选时,属性改变了,页面显示没有改变。经百度发现是JQUERY版本的问题。
$('#checkAll').click(function(){
                var current = $(this)
                $('.checkbox').each(function(){
                    debugger;
               	 if(current.is(':checked')) {
               		 $(this).prop('checked', true);
               	 } else {
               		 $(this).prop('checked', false);
               	 }
                });
            })
把attr换成prop即可解决。
 
                    
                     
                    
                 
                    
                 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号