答案 0 :(得分:1)
jquery之类的东西应该可以解决问题:
在您的<head></head>
部分中输入以下内容:
<style>
.subCat {
display: none;
}
</style>
然后在您的<body></body>
中替换为此的html:
<label>Region :</label>
<select id="selRegion" class="custom-select form-control">
<option value="">Select Region</option>
<option value="central" id="Central">Central</option>
<option value="northern" id="Northern">Northern</option>
</select>
<label>Node Pair :</label>
<select id="selCentral" onchange="getCentral(this)" class="subCat">
<option value="">Select Central</option>
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
<select id="selNorthern" onchange="getNorthern(this)" class="subCat">
<option value="">Select Northern</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<script>
$(function() {
$("#selRegion").change(function() {
$(".subCat").hide();
var val = $(this).val();
if(val == "central") {
$("#selCentral").show();
} else if(val == "northern") {
$("#selNorthern").show();
}
});
});
</script>
希望这会有所帮助。