jQuery Form How to - Check if a checkbox is checked








Question

We would like to know how to check if a checkbox is checked.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.9.1.js'></script>
</head><!--from w w w .jav  a 2 s .  c o m-->
<body>
  <input type="checkbox" id="checkbox-remember" checked="checked" />
  <input type="button" value="test" onclick="console.log($('#checkbox-remember').get(0).checked);"
</body>
</html>

The code above is rendered as follows: