1
我目前正在做一個項目。我有2個單選按鈕,1)單向2)往返。當用戶試圖選擇單向單選按鈕時,返回文本字段將被隱藏。選中單選按鈕時顯示或隱藏字段codeigniter
我看到一個線程和有人對此問題的評論。場景:我選擇單向單選按鈕,返回字段將消失,是的,它正在工作,但有一些問題。如果我改變主意,從單向單選按鈕到往返行程,該怎麼辦?問題是回場沒有回來
** **查看
//我的單選按鈕
<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>
喜先生,我有一個問題,是什麼我可以做什麼來防止每當我選擇一次旅行時顯示「需要返回字段」的驗證? – Angel