根据屏幕分辨率运行 jquery 代码的正确方法
我的网站上有一个多级巨型菜单(使用 jquery 插件),但是,当在移动设备上查看该网站时,我想在菜单上运行不同的 JS 代码,以便有一个适合移动设备的选择菜单。我检查要运行哪些代码的正确方法是什么,例如屏幕宽度是否小于 768px?有处理这个问题的标准方法吗?
I have a multi-level mega menu on my site (using jquery plugin), however, when the site is being viewed on a mobile device, I want to run different JS code on the menu, in order to have a mobile friendly select menu. What is the correct way for me to check which code to run, something like if screen width less than 768px wide? Is there a standard way of dealing with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查
window.screen
对象。check the
window.screen
object.您好,根据问题,您可以使用
link
标记中的媒体属性来更改样式和代码有关详细说明,请参阅此处的博客。
创建-mobile-version-of-your-website
Hi as per the Question you can change the styles and code by using media attribute in your
link
tagFor detailed explaination refer the blog here..
Create-a-mobile-version-of-your-website