Get value if checkbox checked

后端 未结 6 1372
情歌与酒
情歌与酒 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:10

    Use the isChecked and on inside a document.ready

    $(document).ready(
        $("#getusb").on('change',function(){
           if($(this).is(':checked')){
             $('.active-usb').text($(this).val());
           }  
           else{
             $('.active-usb').text('');
           }
        });
        )
    

提交回复
热议问题