单击按钮后如何重置 Bootstrap-select 的值 [英] How to reset value of Bootstrap-select after button click

查看:23
本文介绍了单击按钮后如何重置 Bootstrap-select 的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Bootstrap-select 插件 (https://silviomoreto.github.io/bootstrap-select/) 用于我的下拉选择框.单击按钮后,我希望该框刷新并重置选定"选项.这是下拉菜单

I am using Bootstrap-select plugin (https://silviomoreto.github.io/bootstrap-select/) for my dropdown select box. After I click a button, I want the box to refresh and the "selected" option to reset. This is the dropdown

<select id="dataPicker" class="selectpicker form-control">
  <option value="default" selected="selected">Default</option>
  <option value="one">One</option>
  <option value="two">Two</option>
  <option value="three">Three</option>
</select>

这是我的尝试,不起作用.关于它应该如何的任何想法?

And this is my attempt at it, does not work. Any ideas on how it should be?

$("#dataPicker option:selected").val('default');
$("#dataPicker").selectpicker("refresh");

推荐答案

没有option:selected"

Without "option:selected"

$("#dataPicker").val('default');
$("#dataPicker").selectpicker("refresh");

这篇关于单击按钮后如何重置 Bootstrap-select 的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆