jQuery - jQuery on change collect all checkbox names by norlihazmey ghazali
http://stackoverflow.com/questions/35905009/jquery-on-chnage-collect-all-checkbox-names-and-parse-it-as-string/35905161#35905161
by Norlihazmey Ghazali
HTML
<p id="textList"></p>
<div id="userList">
<input type="checkbox" data-name="John" name="users[]" value="1">
<input type="checkbox" data-name="Peter" name="users[]" value="2">
<input type="checkbox" data-name="Mike" name="users[]" value="3">
</div>
JavaScript
$('#userList').on('change', 'input', function(e) {
var names = $(e.delegateTarget).find(':checkbox:checked').map(function(v, i) {
return $(i).data('name');
}).get();
$('#textList').text(names);
})