javascript - 鼠标滚轮停止滚动时获取Value

标签 javascript html mousewheel

我是编程新手,正在寻找鼠标滚动操作,我的 onmouseup 命令可以工作,但找不到鼠标滚动操作。

当鼠标滚动停止滚动且并非所有滚动操作停止时,我需要getValue

如果有人能帮助我,这将是一个很大的帮助。这是我正在使用的代码。

<div tabindex="0" id="mup" class="my results"
    style="width:649px;height:649px;"
    onmouseup="javascript:getValue('','')"
    mousescroll="javascript:getValue('','')">

最佳答案

您需要监听 onmousewheelonwheel 事件:

<div id="scroll" onwheel="onWheel();" onmousewheel="onWheel();">

然后你需要一个计时器来检查滚动何时完成:

var theTimeout;
function onWheel(){
    clearTimeout(theTimeout);
    theTimeout=setTimeout(function(){
        doSomething();
    },500);
};

查看此JSFiddle example .

关于javascript - 鼠标滚轮停止滚动时获取Value,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20205466/

相关文章:

php - .htaccess 重写传递 2 个参数的 URL

javafx - 如何禁用 ScrollBar (JavaFX) 中的水平滚动?

javascript - 处理 Microsoft Edge 浏览器中奇怪的倒转轮事件 deltaX?

Delphi - WM_MOUSEWHEEL双重处理

javascript - 动态颜色变化的脚本

javascript - Ag-Grid 树状结构根据验证将 cellClass 附加到 NodeChildren 单元

Javascript 对象与 map 性能(Chrome、V8、Node JS)

php - 集合中所有可能的组合

javascript - JQuery 从字符串内部获取文本

javascript - 折叠 Accordion 时,Bootstrap 单选按钮不检查