Jquery水平滚动错误

时间:2013-05-08 10:42:29

标签: javascript jquery

我在实现一个水平滚动的jquery插件时遇到了麻烦。问题是,它不会滚动水平,即使我遵循每条指令。

以下是演示: http://www.designedbyaturtle.co.uk/demos/horizontal-scrolling/

我的演示http://jsbin.com/ezizoz/1

有人可以帮助我

  <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

  <html>
  <head>


  <script src="http://www.designedbyaturtle.co.uk/demos/horizontal-scrolling/jquery.mousewheel.min.js"></script>    <meta charset="utf-8" />

  <script type = "text/javascript" src ="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>


  <script>
        $(document).ready(function() {

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

        });
    </script>

  </head>

  <body>

  dwdddddddddddddddddddddddddddddddddddd
  dwdddddddddddddddddddddddddddddddddddddwdddddddddddddddddddddddddddddddddddddwdddddddddddddddddddddddddddddddddddddwdddddddddddddddddddddddddddddddddddddwdddddddddddddddddddddddddddddddddddddwdddddddddddddddddddddddddddddddddddddwdddddddddddddddddddddddddddddddddddddwdddddddddddddddddddddddddddddddddddddwdddddddddddddddddddddddddddddddddddd
  </body>
  </html>

2 个答案:

答案 0 :(得分:2)

你也必须包括CSS ..

然后它起作用

http://jsbin.com/ezizoz/4

查看此演示

答案 1 :(得分:0)

它正在运作。 只需交换脚本行。首先包括jquery文件,然后是mousewheel文件。

<meta charset="utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="http://www.designedbyaturtle.co.uk/demos/horizontal-scrolling/jquery.mousewheel.min.js"></script>