jquery - 为什么 $(document).width() 在 jQuery 中不起作用?
问题描述
试图让它工作:
width = $(document).width();
if (width > 600) {
$('#anim').animate({
width: '100vw',
}, 500, "linear");
} else {
$('#anim').remove();
}
无论宽度大小如何,动画似乎都会运行?
PS不想使用 $(window).width()
有任何想法吗??
解决方案
弄清楚了!
解决方案是将 (document) 设置为 (document.documentElement)
推荐阅读
- r - 如何计算选择中的项目数?
- c# - 如何解决:运行时封送处理程序不能封送 '' 的至少一个参数
- java - 从编码的私钥字节中提取算法 ID
- vbscript - 如何使用 vbscript 从目录中随机播放声音文件
- matplotlib - Matplotlib,在高分辨率图像中看不到单个非零像素
- javascript - Tesseract.js 示例返回 Uncaught TypeError: Tesseract.TesseractWorker is not a constructor
- python - 从数据框中的文本到大型语料库
- flutter - 我无法使用 stdout.write 打印到 VSCode 的控制台
- ruby-on-rails - Rails:ArgumentError - 您无法定义已定义的列
- java - 导入函数 Java - Eclipse