当我点击选择id = 1的item2时,我能够显示隐藏的DIV,如果我点击id = 0的项目0,我需要再次隐藏所显示的DIV。
div class="ddl-select input-group-btn">
<select id="search-engine-combobox" class="selectpicker show-tick form-control" data-style="btn btn-default " onchange="showDiv(this)" >
<option value="0">All Banks</option>
<option value="1">Bank Type</option>
</select>
</div>
<div class="form-group " id="hidden_div" style="display: none;" >
<select id="banktype" class="selectpicker show-tick bank-type">
<option data-icon="glyphicon-heart">Microfinance</option>
<option data-icon="glyphicon-heart">Home loan</option>
<option data-icon="glyphicon-heart">certificate deposit</option>
</select>
</div>
<script type='text/javascript'>
function showDiv(elem){
if(elem.value == 1)
document.getElementById('hidden_div').style.display = "block";
}
else if (elem.value == 0) {}{
???????
}
</script>
答案 0 :(得分:1)
document.getElementById('hidden_div').style.display = "none";
答案 1 :(得分:1)
检查下面你希望我的预期: - )
<div class="ddl-select input-group-btn">
<select id="search-engine-combobox" class="selectpicker show-tick form-control" data-style="btn btn-default " onchange="showDiv(this)" >
<option value="0">All Banks</option>
<option value="1">Bank Type</option>
</select>
</div>
<div class="form-group " id="hidden_div" style="display: none;" >
<select id="banktype" class="selectpicker show-tick bank-type">
<option data-icon="glyphicon-heart">Microfinance</option>
<option data-icon="glyphicon-heart">Home loan</option>
<option data-icon="glyphicon-heart">certificate deposit</option>
</select>
</div>
<script type='text/javascript'>
function showDiv(elem){
var targetElm = document.getElementById('hidden_div');
if(elem.value == 1) {
targetElm.style.display = "block";
}
else if (elem.value == 0) {
targetElm.style.display = "none";
}
}
</script>
&#13;