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

时间:2016-08-30 09:21:51

标签: html5 twitter-bootstrap-3 bootstrap-select

我正在使用Bootstrap Select进行实时搜索。

我的选择仅包含年份列表。因此,在移动设备上,我想要弹出数字键盘,而不是全文。这在理论上很容易做到:改变type of the input to tel,你就完成了!

但是,我认为Bootstrap Select's documentationissues无法做到这一点。你知道有什么方法可以达到这个目的吗?

2016-09-01:我在Bootstrap Select的Github上打开了feature request

1 个答案:

答案 0 :(得分:1)

你可以尝试通过在加载select之后改变搜索输入类型,方法是通过类似这样的方式监听bootstrap-choices事件:

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