jQuery Form How to - Get all unchecked radio buttons








Question

We would like to know how to get all unchecked radio buttons.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.6.3.js'></script>
<script type='text/javascript'>
$(window).load(function(){<!--from  www .  j a  va 2s.  c  o  m-->
    console.log($('input').not(':checked'));
});
</script>
</head>
<body>
  <input type="checkbox" id="i1" />
  <input type="checkbox" id="i2" checked="checked" />
  <input type="checkbox" id="i3" checked="checked" />
  <input type="checkbox" id="i4" />
</body>
</html>

The code above is rendered as follows: