首页 > 解决方案 > 为什么 $(document).width() 在 jQuery 中不起作用?

问题描述

试图让它工作:

width = $(document).width();
  if (width > 600) {
    $('#anim').animate({
      width: '100vw',
  }, 500, "linear");
} else  {
  $('#anim').remove();
}

无论宽度大小如何,动画似乎都会运行?

PS不想使用 $(window).width()

有任何想法吗??

标签: jqueryjquery-animate

解决方案


弄清楚了!

解决方案是将 (document) 设置为 (document.documentElement)


推荐阅读