开发者

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);
    });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜