show and hide div based on checkbox selection using javascript

后端 未结 1 697
情书的邮戳
情书的邮戳 2021-01-29 16:03

Hi I have a requirement for hiding and displaying the division based on checkbox selection. Currently I have to show and hide 10 division and 10 checkbox is provided for that. A

1条回答
  •  情书的邮戳
    2021-01-29 16:34

    You can do so by the following jQuery code:

        $('.checkbox').click(function() {
         if( $(this).is(':checked')) {
            $("#yourdiv").show();
         } else {
            $("#yourdiv").hide();
         }
        });
    

    Change the #yourdiv - and .checkbox to your CSS identifiers.

    0 讨论(0)
提交回复
热议问题