How to use jQuery to show/hide divs based on radio button selection?

后端 未结 8 698
暗喜
暗喜 2020-11-30 05:38

I have some radio buttons and I\'d like to have different hidden divs show up based on which radio button is selected. Here\'s what the HTML looks like:

<         


        
8条回答
  •  Happy的楠姐
    2020-11-30 06:06

    $(document).ready(function(){ 
        $("input[name=group1]").change(function() {
            var test = $(this).val();
            $(".desc").hide();
            $("#"+test).show();
        }); 
    });
    

    It's correct input[name=group1] in this example. However, thanks for the code!

提交回复
热议问题