点击单选按钮改变div显示隐藏

来源:互联网 发布:淘宝登录异常异地登录 编辑:程序博客网 时间:2024/06/16 08:40

点击单选按钮改变div显示隐藏


JQuery:


  
  1. function showCont() {  
  2.   
  3.     switch ($("input[name=selector]:checked").attr("id")) {  
  4.   
  5.     case "noperid":  
  6.   
  7.         $("#noperid_div").show();  
  8.   
  9.         $("#variable_div").hide();  
  10.   
  11.         break;  
  12.   
  13.     case "calender":  
  14.   
  15.         $("#noperid_div").hide();  
  16.   
  17.         $("#variable_div").hide();  
  18.   
  19.         break;  
  20.   
  21.     case "variable":  
  22.   
  23.         $("#noperid_div").hide();  
  24.   
  25.         $("#variable_div").show();  
  26.   
  27.         break;  
  28.   
  29.     default:  
  30.   
  31.         break;  
  32.   
  33. }  
  34.   
  35. }  
HTML:


  1. <input type="radio" name="selector" id="noperid" value="noperid" /> noperid<br />  
  2.   
  3. <div id="noperid_div" style="display: none;">  
  4.   
  5.     <label>start_time</label>  <input type="text" id="start_time_noperid" /><br />  
  6.   
  7. </div>  
  8.   
  9. <input type="radio" name="selector" id="calender" value="calender" /> calender<br />  
  10.   
  11. <input type="radio" name="selector" id="variable" value="variable" /> variable<br />  
  12.   
  13. <div id="variable_div" style="display: none;">  
  14.   
  15.     <label>start_time</label>  <input type="text" id="start_time_variable" /><br />  
  16.   
  17.     <label>end_time</label>  <input type="text" id="end_time_variable" /><br />  
  18.   
  19. </div> 





0 0
原创粉丝点击