如何将滚动事件附加到文本输入?

问题描述 投票:2回答:2

我正在尝试将滚动事件附加到文本输入,以便在向上滚动时,当文本框处于焦点状态时,它将递增其中的数字,而当向下滚动时,它将减小其中的数字。如果为空或NaN,则应将其替换为0,然后继续。

我已经设法将其移至touchmove并单击并单击drag,但由于某些原因,滚动事件未附加到文本框。

http://jsfiddle.net/KBKA7/

$('input').scroll(function(event) {
    $('div').append('scrolled1');
});

$('input').add('.scrollable').on('scroll', function(event) {
    $('div').append('scrolled2');
});

没有事件被触发。

javascript jquery scroll jquery-events textinput
2个回答
-1
投票

jQuery Mouse Wheel Plugin

$('input').mousewheel(function(event) {
    $('div').append('scrolled ');
});

http://jsfiddle.net/KBKA7/2/


2
投票

由于<input type="text">不能滚动。

您是否尝试过使用textarea?效果很好。

Demo

© www.soinside.com 2019 - 2024. All rights reserved.