using Change on an Input and then modifying the input's ATTR?
Given:
html
<input checked="checked" class="l开发者_开发问答ist_completed_checkbox" id="list_item_completed" name="list_item[completed]" type="checkbox" value="1">
jQuery:
$('.list_completed_checkbox').change(function() {
$(this).attr('disabled', 'disabled');
});
When you check or uncheck the checkbox, Why isn't the disabled attr being applied to the input?
Thanks
Your code works for me:
http://jsfiddle.net/jasongennaro/qYe96/
Perhaps something else is interfering?
i don't think an input has a change event. you might want to do a focus or blur depending on what you need.
$('.list_completed_checkbox').blur(function() {
$(this).attr('disabled', 'disabled');
});
try this:
$('.list_completed_checkbox').change(function() {
$(this).attr('disabled', true);
});
精彩评论