Get value if checkbox checked

后端 未结 6 1365
情歌与酒
情歌与酒 2021-01-23 14:21

I\'m using a jQuery function to get the value of an checked checkbox.

How to hide the value in the span class \"active-usb\" if the checkbox is not checked anymore?

6条回答
  •  囚心锁ツ
    2021-01-23 15:07

    Use this Demo here

    $("#getusb").on('change',function(){
        if($('#getusb').prop('checked')== true){
    $('.active-usb').text($("#getusb:checkbox:checked").val());  
        }else{
            $('.active-usb').text('');  
        }
    }).change();   
    

提交回复
热议问题