When Checkbox is Checked Expand Div

后端 未结 7 1612
野性不改
野性不改 2021-02-10 16:52

I have a checkbox:


This content should app
7条回答
  •  深忆病人
    2021-02-10 17:13

    Attach a change event, and check whether a checkbox is checked or not. If the checkbox is checked, show the div. Otherwise, hide it:

    $('#mycheckbox').change(function(){
        if(this.checked) {
            $(this).next().show();
        } else {
            $(this).next().hide();
        }
    });
    

    You should also have a look at the jQuery docs, before asking such a trivial question.

提交回复
热议问题