【发布时间】:2017-11-04 21:12:06
【问题描述】:
我目前正在做一个项目。我有 2 个单选按钮,1)一种方式 2)往返。当用户尝试选择单向单选按钮时,返回文本字段将隐藏。
我看到了一个线程和有人评论这个问题。场景:我选择了单向单选按钮,返回字段将消失,是的,它正在工作,但有一些问题。如果我改变主意,从单向单选按钮更改为往返行程怎么办?问题是返回字段没有回来
**查看**
//我的单选按钮
<div class="pure-u-1-1 radiobtn">
<form action="">
<input type="radio" name="flight_type" value="one_way" class="onew" style="" >One Way
<input type="radio" name="flight_type" class="roundw" style="" checked>Round Trip
</form>
</div>
// 将隐藏/显示的返回字段
<div class="pure-u-1-1 dr" id="try">
<label for="return" class="drr">Return</label>
<input type="text" id="return" name="return" class="departreturn"><br>
</div>
JS
<script type="text/javascript">
$(document).on('change', 'input:radio[name=flight_type]', function(){
$('div[id^="try"]').hide(); // hide all DIVs begining with "my_radio_"
$('#' + $(this).attr('id') + '_text').show(); // show the current one
});
</script>
【问题讨论】:
标签: javascript php codeigniter