In this post Asp.Net jQuery loop all checkbox
values in Page,
we shall see on how to loop through all the checked checkboxes in the page and
get the values of the checkboxes using jQuery.
We can loop through all the checkboxes in the page by
filtering the type checkbox in the page elements as follows and get the values.
$("input[type=checkbox]").each(function() {
alert($('label[for=' + this.id
+ ']').html() + '
=> ' + $(this).is(':checked'));
});
To loop through all the checkboxes in the page on the
click event of a button use the following script.
// Loop through - Get CheckBox Label/Values
$('#cmdGetValues').click(function(event)
{
event.preventDefault();
$("input[type=checkbox]").each(function() {
alert($('label[for='
+ this.id + ']').html()
+ ' => ' + $(this).is(':checked'));
});
});
To see a
full example using jQuery and Checkbox refer to the post Asp.Net jQuery checkbox Tutorial.
Related Posts
No comments:
Post a Comment