Remove attribute “checked” of checkbox

后端 未结 9 1227
野的像风
野的像风 2020-12-11 00:11

I need remove the attribute \"checked\" of one checkbox when errors occur.

The .removeAttr function not work. Any idea? :/

HTML

9条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-11 00:43

    You could try $(this):

    $("#captureAudio").live("change", function() {
        if($(this).val() !== undefined) { /* IF THIS VALUE IS NOT UNDEFINED */
                navigator.device.capture.captureAudio(function(mediaFiles) {
                console.log("audio");
            }, function() {
                $(this).removeAttr('checked'); /* REMOVE checked ATTRIBUTE; */
                /* YOU CAN USE `$(this).prop("checked", false);` ALSO */
                _callback.error;
            }, {limit: 1});
        }
    });
    

提交回复
热议问题