Returning Data From Function
Hi there,
I am trying to return the value of a 'data-value' attribute from a list of checkboxes:
HTML:
- <div id="disableDays">
- <div class="field">
- <input type="checkbox" id="Sunday" class="is-checkradio" name="Sunday" data-value="0">
- <label for="Sunday" class="label">Sunday</label>
- </div>
- </div>
JQUERY
-
dayValue = $('#disableDays input:checked').each(function() {
-
return $(this).attr('data-value')
-
});
If I console.log 'dayValue' I get 'input#Sunday.is-checkradio' as opposed to '0'. If I change the attr to 'name' or 'Id' I get the same response. Why I am not getting the attribute value returned here and what do I need to change to achieve this?
Thanks