考虑两个选择框 A 和 B
A 有选项:car
, bike
.
B 有选项car1
, car2
, bike1
,bike2
When car
is selected Select Box A, then select box B should have only the following options car1
andcar2
怎么做?谢谢。
考虑两个选择框 A 和 B
A 有选项:car
, bike
.
B 有选项car1
, car2
, bike1
,bike2
When car
is selected Select Box A, then select box B should have only the following options car1
andcar2
怎么做?谢谢。
<select id="vehicle">
<option>car</option>
<option>bike</option>
</select>
<select id="vehicle-type">
<option>--</option>
<option vehicle="car">car1</option>
<option vehicle="car">car2</option>
<option vehicle="bike">bike1</option>
<option vehicle="bike">bike2</option>
</select>
$(function() {
$('#vehicle').on('change', function() {
var vehileType = $('#vehicle').val();
$('#vehicle-type option').hide();
$('#vehicle-type option[vehicle="'+vehileType+'"]').show();
});
});
你可以试试这个 JSFiddle 例子: