选择选项后,如何使用javascript隐藏和显示div?

选择选项后,如何使用javascript隐藏和显示div?,javascript,jquery,html,Javascript,Jquery,Html,所以我一直在尝试为我的网站项目创建一个成本估算表。整个想法是,我将准备大约10个问题,网站将只显示客户回答前一个问题后的下一个问题 在选择而不是收音机中提供选项之前,它工作正常。即使客户已经回答了前面的问题,它也不会显示下一个问题 我不太确定我做错了什么,希望这里的peeps能给我一个方向 $(文档).ready(函数(){ $(“#问题”).hide(); $(“品牌”).hide(); $(“#ipmodel”).hide(); $(“#stype”).hide(); $(“#sgsmod

所以我一直在尝试为我的网站项目创建一个成本估算表。整个想法是,我将准备大约10个问题,网站将只显示客户回答前一个问题后的下一个问题

选择
而不是
收音机
中提供选项之前,它工作正常。即使客户已经回答了前面的问题,它也不会显示下一个问题

我不太确定我做错了什么,希望这里的peeps能给我一个方向

$(文档).ready(函数(){
$(“#问题”).hide();
$(“品牌”).hide();
$(“#ipmodel”).hide();
$(“#stype”).hide();
$(“#sgsmodel”).hide();
$(“#sgnmodel”).hide();
$(“#nmodel”).hide();
$(“#smodel”).hide();
$(“#打开”).hide();
$(“#liquiddamage”).hide();
$(“#结果”).hide();
var input=document.getElementById('phone');
document.getElementById('phone_no')。addEventListener('click',function(){
showBrand();
hideProblem();
hideIpmodel();
hideStype();
hideSgsmodel();
hideSgnmodel();
hideNmodel();
hideSmodel();
hideTurnon();
hideliquid损害();
});
document.getElementById('phone_yes')。addEventListener('click',function(){
showBrand();
hideProblem();
hideIpmodel();
hideStype();
hideSgsmodel();
hideSgnmodel();
hideNmodel();
hideSmodel();
hideTurnon();
hideliquid损害();
});
document.getElementById('applephone')。addEventListener('click',function(){
showBrand();
hideProblem();
showIpmodel();
hideStype();
hideSgsmodel();
hideSgnmodel();
hideNmodel();
hideSmodel();
hideTurnon();
hideliquid损害();
});
document.getElementById('gss')。addEventListener('click',function(){
showBrand();
hideProblem();
hideIpmodel();
showStype();
showSgsmodel();
hideSgnmodel();
hideNmodel();
hideSmodel();
hideTurnon();
hideliquid损害();
});
document.getElementById('samsungphone')。addEventListener('click',function(){
showBrand();
hideProblem();
hideIpmodel();
showStype();
hideSgsmodel();
hideSgnmodel();
hideNmodel();
hideSmodel();
hideTurnon();
hideliquid损害();
});
document.getElementById('gns')。addEventListener('click',function(){
showBrand();
hideProblem();
hideIpmodel();
showStype();
hideSgsmodel();
showSgnmodel();
hideNmodel();
hideSmodel();
hideTurnon();
hideliquid损害();
});
document.getElementById('nokiaphone')。addEventListener('click',function(){
showBrand();
hideProblem();
hideIpmodel();
hideStype();
hideSgsmodel();
hideSgnmodel();
showNmodel();
hideSmodel();
hideTurnon();
hideliquid损害();
});
document.getElementById('sonyphone')。addEventListener('click',function(){
showBrand();
hideProblem();
hideIpmodel();
hideStype();
hideSgsmodel();
hideSgnmodel();
hideNmodel();
showSmodel();
hideTurnon();
hideliquid损害();
});
document.getElementById('otherphone')。addEventListener('click',function(){
showBrand();
hideProblem();
hideIpmodel();
hideStype();
hideSgsmodel();
hideSgnmodel();
hideNmodel();
hideSmodel();
hideTurnon();
hideliquid损害();
});
函数showProblem(){
$(“#问题”).show();
}
函数hideProblem(){
$(“#问题”).hide();
}
函数showBrand(){
$(“品牌”).show();
}
函数hideBrand(){
$(“品牌”).hide();
}
函数showIpmodel(){
$(“#ipmodel”).show();
}
函数hideIpmodel(){
$(“#ipmodel”).hide();
}
函数showStype(){
$(“#stype”).show();
}
函数hideStype(){
$(“#stype”).hide();
}
函数showSgsmodel(){
$(“#sgsmodel”).show();
}
函数hideSgsmodel(){
$(“#sgsmodel”).hide();
}
函数showSgnmodel(){
$(“#sgnmodel”).show();
}
函数hideSgnmodel(){
$(“#sgnmodel”).hide();
}
函数showNmodel(){
$(“#nmodel”).show();
}
函数hideNmodel(){
$(“#nmodel”).hide();
}
函数showSmodel(){
$(“#smodel”).show();
}
函数hideSmodel(){
$(“#smodel”).hide();
}
函数showTurnon(){
$(“#打开”).show();
}
函数hideTurnon(){
$(“#打开”).hide();
}
函数showLiquiddamage(){
$(“#liquiddamage”).show();
}
函数hideLiquiddamage(){
$(“#liquiddamage”).hide();
}
函数showResult(){
$(“#结果”).show();
}
函数hideResult(){
$(“#结果”).hide();
}
});

它是平板电脑还是手机?
这是一个平板电脑。 这是一部电话。
您的手机是什么品牌的?
苹果
三星
诺基亚
索尼
其他
您的手机是什么型号的?
iPhone5 iphone5c iphone5s iphone6 iphone6plus iPhone SE iphone6s iPhone 6s Plus iPhone7 iPhone7 Plus iPhone8 iPhone8 Plus
<div class="form-group text-center">
      <b>Is it a tablet or a phone?</b><br />
      <div class="radio" id="phone">
        <label>
           <input type="radio" name="phone" id="phone_yes" value="1" class="phone_values">
               It's a tablet.
        </label>

      </div>
      <div class="radio">
        <label>
           <input type="radio" name="phone" id="phone_no" value="0" class="phone_values">
             It's a phone.
        </label>
      </div>
    </div>
$(document).ready(function() {
   showProblem();
   hideBrand();
   hideProblem();
   hideIpmodel();
   hideStype();
   hideSgsmodel();
   hideSgnmodel();
   hideNmodel();
   hideSmodel();
   hideTurnon();
   hideLiquiddamage();


   var phone_values = document.getElementsByClassName( "phone_values" );

   for( var a = 0; a < phone_values.length; a++ ) {

      phone_values[a].addEventListener( "click", function() {

         showBrand(); //call the function you want to show next. 
                      //no need to call hide functions.

      }

   } 

} );
document.getElementById('gns').addEventListener('click', function() {
    showBrand();
    hideProblem();
    hideIpmodel();
    showStype(); //show
    hideSgsmodel();
    showSgnmodel();
    hideNmodel();
    hideSmodel();
    hideTurnon();
    hideLiquiddamage();
  });

  document.getElementById('nokiaphone').addEventListener('click', function() {
    showBrand();
    hideProblem();
    hideIpmodel();
    hideStype(); //hide*
    hideSgsmodel();
    hideSgnmodel();
    showNmodel();
    hideSmodel();
    hideTurnon();
    hideLiquiddamage();
  });