【问题标题】:how to clear a timeout when the users screen's height is smaller then 250px in javascript/jquery当用户屏幕的高度小于javascript / jquery中的250px时如何清除超时
【发布时间】:2017-09-01 19:02:40
【问题描述】:

我正在制作一个网站,当用户的屏幕高度小于 250 像素时,我想在 javascript 中清除超时。这是website 的链接,因为该网站处于开发阶段,请使用 chrome 或 firefox 进行浏览.我要删除的元素的 id 为 intro-div。

【问题讨论】:

  • 你的代码是..?
  • 所以在代码运行时检测大小。如果它小于宽度,不要运行代码.... 看起来很简单。
  • if(window.screen.availHeight
  • 欢迎来到 Stack Overflow。请阅读how to ask a question 并提供minimal reproducible examples。

标签: javascript jquery html css


【解决方案1】:

// 开始超时 var promise = $timeout(function() {}, 1000);

// 停止挂起的超时 $timeout.cancel(promise);

【讨论】:

  • 你能给个jsfiddle吗
【解决方案2】:

if(window.innerWidth<=250) document.getElementById('intro-div').remove();

或者用css:

@media screen and (max-width:250px){
    #intro-div{ display:none; }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-12-01
    • 1970-01-01
    • 2020-12-25
    • 1970-01-01
    • 1970-01-01
    • 2018-11-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多