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

jquery:

function showCont() {

    switch ($("input[name=selector]:checked").attr("id")) {

    case "noperid":

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

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

        break;

    case "calender":

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

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

        break;

    case "variable":

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

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

        break;

    default:

        break;

}

}

html:

<input type="radio" name="selector" id="noperid" value="noperid" /> noperid<br />

<div id="noperid_div" style="display: none;">

    <label>start_time</label>  <input type="text" id="start_time_noperid" /><br />

</div>

<input type="radio" name="selector" id="calender" value="calender" /> calender<br />

<input type="radio" name="selector" id="variable" value="variable" /> variable<br />

<div id="variable_div" style="display: none;">

    <label>start_time</label>  <input type="text" id="start_time_variable" /><br />

    <label>end_time</label>  <input type="text" id="end_time_variable" /><br />

</div>


posted @ 2015-06-10 00:16  Java夜未眠  阅读(13)  评论(0)    收藏  举报