单选按钮的点击事件

单选按钮的点击事件:
HTML代码:

<td width="15%" class="td_title">按设备或医生</td>
    <td>
        <input type="radio" id="sMachineCode" name="choice"  value='1' checked="checked"/>设备编号&nbsp;
        <input type='radio' id='visitDoc' name='choice' value='2' >随访医生&nbsp;
        <input type='text' id='smachined' name='sMachineCode' placeholder="请输入设备编号" value='' >
        <input type='text' id='doctor' name='visitDoc' style="display:none" placeholder="请输入医生姓名" value='' > 
</td>
JS代码:
$(function{
   $('input:radio[name="choice"]').change(function(){

            var v = $(this).val();

            if (v =="2"){

            $("#doctor").show();

            $("#smachined").hide(); 

            }else{

            $("#doctor").hide();

            $("#smachined").show();

            }

            });
});

猜你喜欢

转载自blog.csdn.net/shenxiaomo1688/article/details/80809913