本文摘自PHP中文网,作者青灯夜游,侵删。

相关教程推荐:《bootstrap视频教程》
PC端项目中经常会出现大量的数据列表页面,涉及到下拉框选择筛选条件;
当时用到bootstrap-select下拉框时该如何点击重置按钮就清除下拉框的选中状态,恢复默认状态呢?
如【图1】

当我们选择摸一个条件之后
如【图2】

此时点击重置按钮要将【图2】的状态回到【图1】,我们会使用很多方法,比如:
1 2 3 4 5 6 7 8 | $( "#loc_province_search" ).attr( "lang" , '0' );
$( "#loc_city_search" ).attr( "lang" , '0' );
$( "#loc_town_search" ).attr( "lang" , '0' );
$( ".txt_classification" ).attr( "lang" , '0' );
$( ".txt_industry" ).attr( "lang" , '0' );
$( ".txt_segmentation" ).attr( "lang" , '0' );
$( ".customer_busi_status2" ).attr( "lang" , '0' );
$( "#searchkey" ).attr( "lang" , '0' );
|
或者这样:
1 | document.getElementById( "selectid" ).options.length = 0;
|
但是我们找了很多方法对于bootstrap-select下拉框都不会生效,其实就是因为bootstrap-select需要在清楚的基础上对当前的下拉框进行刷新,重新载入
代码如下:
1 2 | document.getElementById( "searchPayState" ).options.selectedIndex = 0;
$( "#searchPayState" ).selectpicker( 'refresh' );
|
以上代码即可解决问题
更多编程相关知识,请访问:编程学习!!
以上就是bootstrap-select下拉框如何清除选中的状态?的详细内容,更多文章请关注木庄网络博客!
相关阅读 >>
bootstrap干什么用的
bootstrap如何读
bootstrap怎么实现可关闭tab
bootstrap 怎么关闭弹出框
easyui和bootstrap区别
bootstrap中如何设置表单的宽高
bootstrap删格系统如何理解
bootstrap怎么实现自适应高度
bootstrap icon 不显示怎么办
bootstrap 如何设置移动端元素隐藏
更多相关阅读请进入《bootstrap-select》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » bootstrap-select下拉框如何清除选中的状态?