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

来源:互联网 发布:app个性化推荐算法 编辑:程序博客网 时间:2024/06/05 11:20

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>


1 0
原创粉丝点击