Check value for checked checkboxes

Check value for checked checkboxes

My PHP-script generates checkboxes following this pattern:
  1. <input name="checkbox_group[]" id="checkbox_1" value="1" />
  2. <input name="checkbox_group[]" id="checkbox_2" value="2" />

I have tried every solutions I could find, like these:

  1. var values = new Array();
    $
    .each($("input[name='
    checkbox_group[]']:checked"), function() {
      values
    .push($(this).val());
     
    // or you can do something to the actual checked checkboxes by working directly with  'this'
     
    // something like $(this).hide() (only something useful, probably) :P
    });
and
  1. var items = [];
    $
    ("input[name='
    checkbox_group[]']:checked").each(function(){items.push($(this).val());});
NO LUCK AT ALL. What am i doing wrong? I use the latest release of jQuery.