i want to show in a div what check boxes have been checked
for example
<input id="checkbox1" type="checkbox"><label for="checkbox1">Checkbox 1</label>
<p>you have selected:</p> <div>checkbox 1</div>
there will be more than 1 check box (37) and i need it to be able to select all the check boxes
i think that make sense
Thanks
You can use:
$(":checkbox").change(function(){
$('div').html($(':checked').map(function(){
return $(this).next().text()
}).get().join(','));
});
Working Demo
This is how I would do it:
$("input[type='checkbox']").change(function(){
$("#checked").empty();
$("input[type='checkbox']:checked").each(function(){
$("#checked").html($("#checked").html() + $(this).next().text() + "<br/>");
});
});
Here is the JSFiddle demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With