更改 Bootstrap select 的实时搜索输入类型

Changing Bootstrap select's live search input type

我正在使用 Bootstrap Select 并开启实时搜索。

我的 select 但是只包含年份列表。因此,在移动设备上,我希望弹出数字键盘,而不是全文。这在理论上很容易做到:更改 type of the input to tel 就大功告成了!

但是,我认为 Bootstrap Select's documentation or issues 没有办法做到这一点。你知道有什么方法可以做到这一点吗?


2016-09-01:我在BootstrapSelect的Github[=17上开了一个feature request =]

您可以尝试在 select 加载后更改搜索输入类型,方法是使用如下内容侦听 bootstrap-selects 事件:

$('#mySelect').on('loaded.bs.select', function () {
    $(this).closest('.bootstrap-select').find('.bs-searchbox input').attr('type', 'tel')
});