So many “check” in this post title. haha~
You can get the checkbox state by the the following jQuery.
// true if checked $('#checkbox-id').is(":checked");
Try the following HTML.
<html> <head> <title>jQuery - Check if Checkbox is CHECKED</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#checkbox-id').click(function() { alert($('#checkbox-id').is(":checked")); // For older version of jQuery //alert($('#checkbox-id').attr('checked')); }); }); </script> </head> <body> <input id="checkbox-id" type="checkbox" /> </body> </html>
Done =)
Reference: jQuery: 判斷 checkbox 是否被選取
It’s not work. Are u sure?
LikeLike
I just tried again the example in Apache 2.2. Every works fine.
Have you checked the chrome console and see if there is any js error?
LikeLike