使用鼠标滚轮在水平列表上进行水平滚动

使用鼠标滚轮在水平列表上进行水平滚动

问题描述:

我正在尝试使用鼠标滚轮进行水平滚动,但似乎不起作用.

I'm attempting a horizontal scroll with the mouse wheel, but doesn't seem to work.

这是我的小提琴

我的主班.selector是具有可滚动overflow

My main class .selector is the one with scrollable overflow

这是JS,我正在尝试使用

This is JS I am trying to initialise the scroll with

 $('.selector').mousewheel(function(e, delta) {
    this.scrollLeft -= (delta * 40);
    e.preventDefault();
});

这是我用于水平滚动的示例 https ://css-tricks.com/snippets/jquery/horz-scroll-with-mouse-wheel/

This is the example I am using for horizontal scroll https://css-tricks.com/snippets/jquery/horz-scroll-with-mouse-wheel/

在此先感谢您的帮助!

谢谢,我忘了在Fiddle中使用jQuery是的,但是,当我在localhost上进行测试时,我使用的是jQuery 1.11.1.干杯们

Thanks all, I forgot jQuery in the Fiddle yeah sorry, but when I was testing on localhost I was using jQuery 1.11.1 so maybe that was the case. Cheers guys

您只是忘记将JQuery添加到您的html

You just forget to add JQuery to your html

http://jsfiddle.net/902tjbzz/

jquery.js: http://code.jquery.com/jquery- 2.1.4.min.js