1

大家好,我在这里工作 jquery 我有三个三个单选按钮,每个选择我有三个 div 我需要选择一个潜水,就像我在选择 div 时为它提供单独的 div 一样,它会正确打开,我需要执行就像当我选择另一个单选按钮时,首先打开的另一个单选按钮应该关闭并选择应该打开我怎么能这样做这是我的代码如下请帮我这样做

                         <form class="form-horizontal" id="zone"> 
                           <label class="control-label" for="Availability">Shipping Zone Type</label>
                <div class="controls">
                <label class="radio">
                    <input type="radio" class="regular-radio" name="radio-1-set" id="radio-1-1"><label for="radio-1-1"></label>
                    This shipping zone is based on one more countries
                    <span class="tooltip-demo"><a data-original-title="Tooltip on right" href="#" rel="tooltip" data-placement="right"><i class="icon-question-sign"></i> </a></span>

                </label>

                <div class="selectbox-bg selectbox-bg-sb3 pull-left " id="shippingZone" style="display:none">
               <select>
                  <option>Choose a Country</option>
                  <option>2</option>
                  <option>3</option>
                  <option>4</option>
                  <option>5</option>
               </select>
               </div> 
                           <label class="radio">
                    <input type="radio" class="regular-radio" name="radio-1-set" id="radio-1-2"><label for="radio-1-2"></label>                     
                    This shipping zone is based on one more state or provinces
                    <span class="tooltip-demo"><a data-original-title="Tooltip on right" href="#" rel="tooltip" data-placement="right"><i class="icon-question-sign"></i> </a></span>
                 </label>
                   <div class="selectbox-bg selectbox-bg-sb3 pull-left " id="shippingzonecountry" style="display:none">
               <select>
                  <option>Choose a Country</option>
                  <option>2</option>
                  <option>3</option>
                  <option>4</option>
                  <option>5</option>
               </select>
               </div>
                  <input type="radio" class="regular-radio" name="radio-1-set" id="radio-1-3"><label for="radio-1-3"></label>                    
                 This shipping zone is based on one more postal or ZIP codes
                        <span class="tooltip-demo"><a data-original-title="Tooltip on right" href="#" rel="tooltip" data-placement="right"><i class="icon-question-sign"></i> </a></span>
                </label>
                <div class="selectbox-bg selectbox-bg-sb3 pull-left " id="zipcode" style="display:none">
               <select>
                  <option>Choose a Country</option>
                  <option>2</option>
                  <option>3</option>
                  <option>4</option>
                  <option>5</option>
               </select>
               </div>  
                         </form>  

在上面我有三个单选按钮和三个 div 我需要选择一个单选按钮,当我选择另一个打开时它应该打开它应该关闭请帮助我这个 sdtha

          thi is my jquery :as fpllows

                $(function () {
                 $("#radio-1-2").click(function () {
           $("#shippingzonestate").show('slow');
             });

          $("#radio-1-2").click(function () {
          $("#shippingzonestate").show('slow');
          $("#shippingzonecountry").show('slow');
           });

          $("#radio-1-3").click(function () {
         $("#zipcode").show('slow');
          $("#Product-Code-SKU").show('slow');
           });

我试过这样但是当我打开另一个应该关闭我怎么能这样做

4

1 回答 1

1

编辑(通用功能)

function showhide(radioname)
{
    $("#shippingzonestate").hide('slow');
    $("#shippingzonecountry").hide('slow');
    $("#zipcode").hide('slow');
    $("#Product-Code-SKU").hide('slow');

   if(radioname=="one")
   {
     $("#shippingzonestate").show('slow');
   }
   if(radioname=="two")
   {
     $("#shippingzonestate").show('slow');
     $("#shippingzonecountry").show('slow');
   }
   if(radioname=="three")
   {
     $("#zipcode").show('slow');
     $("#Product-Code-SKU").show('slow');
   }
}


$(function () {
                 $("#radio-1-2").click(function () {
                       showhide("one");
             });

          $("#radio-1-2").click(function () {
                        showhide("two");
           });

          $("#radio-1-3").click(function () {
                        showhide("three");
           });
}); 

只需使用隐藏方法

  $(function () {
             $("#radio-1-2").click(function () {
       $("#shippingzonestate").show('slow');
        $("#shippingzonecountry").hide('slow');
          $("#zipcode").hide('slow');
      $("#Product-Code-SKU").hide('slow');
         });

      $("#radio-1-2").click(function () {
      $("#shippingzonestate").show('slow');
      $("#shippingzonecountry").show('slow');
          $("#zipcode").hide('slow');
      $("#Product-Code-SKU").hide('slow')
       });

      $("#radio-1-3").click(function () {
     $("#zipcode").show('slow');
      $("#Product-Code-SKU").show('slow');
      $("#shippingzonestate").hide('slow');
      $("#shippingzonecountry").hide('slow');
       });
于 2012-11-26T07:59:41.957 回答