Why clicking on checkbox does not add the attribute checked='checked'
The HTML attribute checked
means: checked by default, when the page loads. This won't change when the checkbox is clicked.
<input type="checkbox" checked="checked"> <!-- The HTML attribute -->
The DOM property checked
is actually the current state of the checkbox and is either true/false. This will change when the checkbox is clicked, but isn't visible when you inspect the HTML.
$('input:check')[0].checked == true;
// Whether or not the checkbox is currently checked
What are you trying to do? Find out if its checked?
$('.user_roles').click(function(){
console.log( $(this).is(':checked'));
});
http://jsfiddle.net/petersendidit/FCrSg/1/