Check value for checked checkboxes
My PHP-script generates checkboxes following this pattern:
- <input name="checkbox_group[]" id="checkbox_1" value="1" />
- <input name="checkbox_group[]" id="checkbox_2" value="2" />
I have tried every solutions I could find, like these:
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
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.