Jquery won't check if my checkboxes are checked
Hey Guys. I wrote a script below to see if the checkboxes are checked or not. This is a quick and dirty example I have. The actual code I will be implementing this to is more dynamic.
The code below is supposed to bring back true or false based on what if the checkboxs has been checked or not.
But for some weird reason its just bringing back false twice. It should be returning true, false on the console.log
Any help would be very much appreciated. Thanks!!!
Here is the link to my JS Fiddle
http://jsfiddle.net/eldan88/jr6tfknh/
- <div class="option_category" id="1"></div>
- <input type="checkbox" checked="checked" class="for1_required">
- <div class="option_category" id="2"></div>
- <input type="checkbox" class="for2_required">
- <input type="submit" name="submit" value="submit">
- </form>
- <script>
- // $('#items').submit(function(){
- $('.option_category').each(function(){
- var cat_id = $(this).attr('id');
-
- var is_checked = $('input[class*=for'+cat_id+'required]').is(':checked');
- console.log(is_checked);
- });