1

I'm using jQuery version 1.8.0 and I'm getting error message as "Uncaught Error: Syntax error, unrecognized expression: unchecked"

jQuery changed unchecked to prop('checked',false) .I tried changing my code but, its not working.

 if($('input[name='+family+']:unchecked').length){
     }

I replaced this to

if($('input[name='+family+']).prop('checked',false).length){
 }
Arun Prakash
  • 421
  • 2
  • 6
  • 20

2 Answers2

6

Use :not selector with :checked:

if($('input[name='+family+']:not(:checked)').length){
   //do something..
}
Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125
2

This should do the trick

var uncheckedElems = $('input[name='+family+']')
.filter(function(){ 
    return !$(this).prop('checked')
});

if(uncheckedElems .length > 0)
{
 //Code here
}
Alen Genzić
  • 1,398
  • 10
  • 17