简体   繁体   English

选择Picker插件Bootstrap下拉列表不适用于手机/平板电脑

[英]Select Picker plugin Bootstrap dropdown not working on mobiles/tablets

I have the select picker plugin for bootstrap ( http://silviomoreto.github.io/bootstrap-select/ ) working on my website. 我的网站上有用于引导程序的选择选择器插件( http://silviomoreto.github.io/bootstrap-select/ )。

Each dropdown option is a link to a different twitter page like so: 每个下拉选项都是一个指向不同Twitter页面的链接,如下所示:

<select class="selectpicker" data-width="100%" name="venue" id="venue" onchange="location = this.options[this.selectedIndex].value;">
     <option value="None Selected">Choose your twitter profile</option>
     <option value="https://twitter.com/LVPLShooters">Liverpool</option>
     <option value="https://twitter.com/LeedsShooters">Leeds</option>
     <option value="https://twitter.com/MancShooters">Manchester</option>
</select>

$('.selectpicker').selectpicker();

It works 100% on laptops and computers. 它可在笔记本电脑和计算机上100%工作。 But when I use a tablet or phone the links dont work. 但是,当我使用平板电脑或电话时,链接不起作用。 Has anyone got any ideas on why this would be doing this? 有谁知道为什么要这么做吗?

Replace location = this.options[this.selectedIndex].value; 替换location = this.options[this.selectedIndex].value; with window.location = this.options[this.selectedIndex].value; window.location = this.options[this.selectedIndex].value; and try 并尝试

Or use jQuery as below: 或使用jQuery ,如下所示:

$('.selectpicker').change(function() {
    window.location = $(this).val();
});

jsFiddle 的jsfiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM