1
上週我發佈了關於基於選項切換隱藏區域的信息。我現在遇到問題,當我點擊下拉選項中的選項時,它不會隱藏/顯示我想要顯示的其他下拉列表。如何根據下拉選項顯示隱藏下拉菜單
我感謝所有幫助:)
jQuery的
$(document).ready(function() {
$('select[name="YourLocation"]').change(function() {
if ($(this).val() == 'Customer Care Center') {
$('.CCC').show();
} else {
$('.CCC').hide();
}
});
});
HTML
<div class="col-md-3">
<div class="form-group">
<label>Your Location</label>
<select name="YourLocation" class="form-control select2" style="width: 100%;" required>
<option value="" disabled selected>Select Your Location</option>
<option value="Branch">Branch</option>
<option value="Region">Region</option>
<option value="Division">Division</option>
<option value="Customer Care Center">Customer Care Center</option>
<option value="Corporate">Corporate</option>
</select>
</div>
<!-- /.form-group -->
</div>
<!-- /.col -->
<div class="col-md-3">
<div class="form-group">
<label></label>
<select name="YourCenter" class="form-control select2 CCC" style="width: 100%;" required>
<option value="" disabled selected>Select Your Center</option>
<option value="Dallas">Dallas</option>
<option value="Los Angeles">Los Angeles</option>
<option value="Phoenix">Phoenix</option>
<option value="Tampa">Tampa</option>
</select>
</div>
<!-- /.form-group -->
</div>
<!-- /.col -->
固定https://jsfiddle.net/jq08398t/2/ – Hackerman
哇,謝謝。這個問題是什麼? – Helene
是的,代碼很好,只有jQuery缺少哈哈。 – skobaljic