jQuery HTML Checkbox
Using jQuery to manipulate Checkboxes can sometimes be testing for us developers, hence I’m sharing some code her in the hope that it may assist with getting the user’s HTML Checkbox selections.
Consider a simple group of checkboxes, each one representing the day of the week.
The relevant jQuery code to achieve this result can be seen below. Please note that #buttons is the container that the checkboxes reside in.
1 2 3 4 5 6 7 8 9 10 | $('#buttons').children(":input[@name='day[]']").bind('click', function() { var str=""; // filter by the checkboxes that have been checked $(this).parent().children("input:checked").each( function() { str = str + $(this).val() + " is checked \n"; }); str != "" ? alert(str) : false; }); |

