I am trying to generate a string of the data attributes (so the chars from M to F)
Attached is my HTML
<div id="days" class="checkbox">
<label>
<input data-date="M" type="checkbox"> Mon
</label>
<label>
<input data-date="T" type="checkbox"> Tues
</label>
<label>
<input data-date="W" type="checkbox"> Wed
</label>
<label>
<input data-date="R" type="checkbox"> Thurs
</label>
<label>
<input data-date="F" type="checkbox"> Fri
</label>
</div>
This is my jQuery:
$(function(){
var days = '';
$("input[type='checkbox']").change(function(){
var item=$(this);
if(item.is(":checked"))
{
days += ($('#days label input').data('date'));
}
});
});
This is what the program looks like:
What happens when I click the days, is, I could click the Wednesday checkbox, but only the M gets appended. I would click Friday checkbox, and the M would be appended.
M
MM
MMM
How do I append the MTWRF as well as remove them when they are unclicked?

.map()function to get the list of checked checkboxes. try this fiddle. jsfiddle.net/pauwtxfd/1 I am returning an array of checked checkboxes. check the console for output