javascript - List of checkboxes checked for specific classes -
i list of names of checkboxes checked in specific div (page-wrap). creating filter of sorts , have treeview of different types color, quality, grain, etc... each has own class assigned them. color has class of color_cb, quality product_cb, grain grain_cb. following code works great 1 of them i'd test 3. there way modify 3.
var selected = []; $('#page-wrap input:checkbox.color_cb:checked').each(function() { selected.push($(this).attr('name')); }); alert(selected.join(","));
i've tried doesn't work.
var selected = []; $('#page-wrap input:checkbox.color_cb:checked input:checkbox.product_cb:checked').each(function() { selected.push($(this).attr('name')); }); alert(selected.join(","));
use comma separator b/w selected element
$('#page-wrap input:checkbox.color_cb:checked ,#page-wrap input:checkbox.product_cb:checked') ^^^^-- add , seperator
or use map()
var selected = $('#page-wrap input:checkbox.color_cb:checked ,#page-wrap input:checkbox.product_cb:checked').map(function () { return $(this).attr('name'); }).get();
Comments
Post a Comment