JQuery控制input的隐藏和显示

来源:互联网 发布:mysql 小于当前时间 编辑:程序博客网 时间:2024/05/16 16:05

radio:

<tr>                    <th class="red">选择类型:</th>                    <td colspan="3">                        <input name="strAppliType" type="radio" value="01" onclick="display(this.value)" checked>出差                       <input name="strAppliType" type="radio" value="03" onclick="display(this.value)" >脱产学习  </br>                     <input name="strAppliType" type="radio" value="04" onclick="display(this.value)" >事假                       <input name="strAppliType" type="radio" value="05" onclick="display(this.value)" >病假                       <input name="strAppliType" type="radio" value="06" onclick="display(this.value)" >年休假  </br>                     <input name="strAppliType" type="radio" value="08" onclick="display(this.value)" >婚假                       </div>                                         </td>                </tr>


input:

<tr id="isshow">     <th>岗  位:</th>               <td >                <input type='text'  name='strStation' id='strStation' class="text_ipt2" >               </td>               <th>工作时间:</th>               <td>                <input type='text'  name='strWorkTime' id='strWorkTime'  class="text_ipt2" > 年               </td>               </tr>


在JavaScript中通过radio的选择来控制input的显示与隐藏

//类型选择后出现请假类型function display(n) {if(n==01||n==03){$("#isshow").find("th:eq(1)").show();$("#isshow").find("td:eq(1)").show();$("#isshow").find("td:eq(0)").attr("colspan","1");}else if(n==06){$("#isshow").find("td:eq(0)").attr("colspan","3");$("#isshow").find("th:eq(1)").hide();$("#isshow").find("td:eq(1)").hide();
}else{ $("#isshow").find("td:eq(0)").attr("colspan","3");$("#isshow").find("th:eq(1)").hide();$("#isshow").find("td:eq(1)").hide();} }

 

页面初始化时input的显示与隐藏

<script type="text/javascript">showtable.loader('TextInput01', 'tr', 'evenOver');$("#isshow").find("th:eq(1)").show();$("#isshow").find("td:eq(1)").show();



 

0 0
原创粉丝点击