我正在使用Select2 jQuery插件来增强我们项目中的<select>元素。然而,在移动设备(智能手机、平板电脑)上,Select2实际上会降低用户体验。在我看来,原生的select元素更好。
我们已经在使用http://detectmobilebrowser.com/的regexp进行智能手机检测了,但它们与平板电脑不匹配(我们希望将智能手机和平板电脑的检测分开)。有没有像detectmobilebrowswer.com这样的写字板正则表达式或其他检测写字板的方法?
发布于 2016-11-06 16:08:54
$(document).ready(function() {
// run test on initial page load
checkSize();
// run test on resize of the window
$(window).resize(checkSize);
});
function checkSize(){
if (window.matchMedia("(min-width: 1024px)").matches) {
$("select").select2();
} else {
$("select").select2("destroy");
}
}发布于 2012-06-14 17:38:09
您可以自己研究一下表的用户代理是什么。
如果您知道这些表的用户代理,那么可以通过PHP或其他方式相应地包含适当的Javascript文件。
Follow this link to find tablet user agents
https://stackoverflow.com/questions/11030145
复制相似问题