我想跟随jsfiddle
进行一些修改https://jsfiddle.net/zqvvuts6/5/
如果在子选项中,用户单击其他,则会显示用于搜索的文本框。
在下拉选项中,如下所示
Swedish Cars (parent)
Volvo (child)
Saab (child)
other ( onclick it should show textbox)
答案 0 :(得分:0)
您可以执行如下所示的操作,即使用“display:none”创建隐藏字段,当选择下拉列表中的“others”选项时,将使用“display:block”属性并搜索输入字段将出现
function checkSelected(elem){
if(elem.value=="6"){
document.getElementById("hiddSearch").style.display="block";
}
else{
document.getElementById("hiddSearch").style.display="none";
}
}
<select id="filter_sport" multiple="multiple" name="filter_sport"
class="selectpicker" title='Choose a Sport' data-actions-box="true" class="show-menu-arrow"
data-selected-text-format="count>3"
data-single-item-selected = "Sport Selected"
data-all-items-selected="All Sports"
ata-multi-item-selected = "Sports Selected" onchange="checkSelected(this)">
<option value="11" selected="selected">Cricket</option>
<option value="15" selected="selected">Football</option>
<option value="3" selected="selected">Hockey</option>
<option value="16" selected="selected">MMA</option>
<option value="6" selected="selected">Others</option>
</select>
<input style="display:none" id="hiddSearch"/>