I am using the Select2 jQuery plugin to enhance <select>
elements in our project. However, on mobile devices (smartphones, tablets), Select2 actually degrades the experience. The native select elements are better, in my opinion.
We're already doing smartphone detection with regexps from http://detectmobilebrowser.com/, but these don't match tablets (and we would like to keep smartphone and tablet detection separate). Is there any reference for tablet regexps like detectmobilebrowswer.com, or another way of detecting tablets?
$(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");
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With