所以我有以下js:
jQuery('.rhmps_aj').click(function(e) {
...
success: function(data){
//Desktop
jQuery('.desktop_less').hide();
jQuery('.desktop_more').show();
//Mobile
jQuery('.mobile_less').hide();
jQuery('.mobile_more').show();
});
有人可以告诉我如何根据内容是通过桌面还是移动设备查看来“禁用”某些功能吗?
例如,对于桌面,我想禁用“移动”功能,对于移动 View 反之亦然。
最佳答案
您可以检查屏幕尺寸的宽度。如果屏幕尺寸小于该宽度,您就可以执行您想要的功能。
示例:
if ($(window).width() < 600) { // if width is less than 600px
MobileFunctions(); // execute mobile function
}
else { // if width is more than 600px
DesktopFunctions(); // execute desktop function
}
关于javascript - 基于移动或桌面的 jQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33640407/