How to only show input fields if checkbox is checked?

前端 未结 6 2360
小鲜肉
小鲜肉 2021-01-02 12:40

Basically, I want to only show these fields if checkbox is selected, if it becomes unselected, disappear.



        
6条回答
  •  情书的邮戳
    2021-01-02 13:32

    Matthews answer works great just that the .live deprecated in jQuery 1.7 use the .on

    $('#supplied').on('change', function(){
        if ( $(this).is(':checked') ) {
            $('#date').show();
        } else {
            $('#date').hide();
        }
    });
    

提交回复
热议问题