Jquery show/hide resetting when page reloads

后端 未结 6 1891
萌比男神i
萌比男神i 2021-01-27 05:16

I\'m new to jquery, but I\'m trying to use it to create a multi-step tabbed form.

One one of the pages, I have radio buttons that will show several fields depending on t

6条回答
  •  灰色年华
    2021-01-27 05:59

    Slightly modifying your jquery by extracting out a method:

        $(document).ready(function() {
    
        //...stuff
    
        ShowHidePanels();
    
        $("input[name='paymentmethod']").change(function() {
            ShowHidePanels();
        });
    
        function ShowHidePanels(){
            if( $("input[name='paymentmethod']:checked").val() == "cheque")
            {
                $("#divcredit").hide();
                $("#divcheque").show();
            }
            else if($("input[name='paymentmethod']:checked").val()== "creditcard")
            {
                $("#divcredit").show();
                $("#divcheque").hide();
            }
        };
    });
    

提交回复
热议问题