$(function(){

    if ((navigator.userAgent.indexOf('MSIE') >= 0)){/*判断是否是IE浏览器*/
var scroll_width = 100;
$("html").on("mousewheel", function(e){
var delta = e.originalEvent.wheelDelta;
if(delta<0){
$("html").scrollLeft($("html").scrollLeft() + scroll_width);
}
else{
$("html").scrollLeft($("html").scrollLeft() - scroll_width);
}
});
}else{
var scroll_width = 100;
var scroll_events = "mousewheel DOMMouseScroll MozMousePixelScroll";
$("body").on(scroll_events, function(e){
var delta = e.originalEvent.wheelDelta
console.log(delta);
var detail= e.originalEvent.detail;
if(!detail){/*谷歌浏览器*/
this.scrollLeft-= (delta);
}else{/*火狐浏览器*/
if(detail>0){
$("html").scrollLeft($("html").scrollLeft() + scroll_width);
}
else{
$("html").scrollLeft($("html").scrollLeft() - scroll_width);
}
}
});
} })

下面是监听鼠标左右键事件

$(document).ready(function(){

     $(window).mousedown(function(event){

     if(event.button==0){

     alert("你点击了左键");

     }else{

     alert("你点击了右键");

     }

     });

     });

关于如何用Jquery监听鼠标滚轮改变横向滚动条的更多相关文章

  1. js事件监听/鼠标滚轮/行为/冒泡/键盘的兼容性写法

    addEvent:function(el,type,fn,capture) { if (window.addEventListener) { if (type === "mousewheel ...

  2. 二、python小功能记录——监听鼠标事件

    1.原文链接 #-*- coding:utf-8 -*- from pynput.mouse import Button, Controller ## ======================== ...

  3. js进阶 12-6 监听鼠标滚动事件和窗口改变事件怎么写

    js进阶 12-6 监听鼠标滚动事件和窗口改变事件怎么写 一.总结 一句话总结:滚动事件scroll(),浏览器窗口调整监听resize(),思考好监听对象. 1.滚动事件scroll()的监听对象是 ...

  4. jquery 监听所有锚点链接实现平滑移动

    jquery 监听所有锚点链接实现平滑移动,地址栏上不会改变链接地址 //监听所有锚点链接实现平滑移动 $('a[href*=#],area[href*=#]').click(function() { ...

  5. java 事件监听 - 鼠标

    java 事件监听 - 鼠标 //事件监听 //鼠标事件监听 //鼠标事件监听有两个实现接口 //1.MouseListener 普通的鼠标操作 //2.MouseMotionListener 鼠标的 ...

  6. jQuery监听事件经典例子

    关键字:jQuery监听事件经典例子  js代码:  ============================================================  $(function( ...

  7. Python——pyHook监听鼠标键盘事件

    pyHook包为Windows中的全局鼠标和键盘事件提供回调. 底层C库报告的信息包括事件的时间,事件发生的窗口名称,事件的值,任何键盘修饰符等. 而正常工作需要pythoncom等操作系统的API的 ...

  8. 50-用Python监听鼠标和键盘事件

    转自:https://www.cnblogs.com/qiernonstop/p/3654021.html 用Python监听鼠标和键盘事件 PyHook是一个基于Python的“钩子”库,主要用于监 ...

  9. 用Python监听鼠标和键盘事件

    PyHook是一个基于Python的“钩子”库,主要用于监听当前电脑上鼠标和键盘的事件.这个库依赖于另一个Python库PyWin32,如同名字所显示的,PyWin32只能运行在Windows平台,所 ...

随机推荐

  1. vedio_note_1

    同步复位 always @ (posedge clk) ....... 异步复位 always @ (posedge clk or negedge rst_n) ....... 异步复位和同步复位的优 ...

  2. CodeForces 670A Holidays

    简单题. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #inclu ...

  3. JDK各版本新增的主要特性

    JDK1.5新特性: 1.自动装箱与拆箱: 2.枚举 3.静态导入,如:import staticjava.lang.System.out 4.可变参数(Varargs) 5.内省(Introspec ...

  4. Mysql登录后看不到数据库

    进入数据库后,只能看到information_schema/test这两个库,其他的数据库都看不到,这是权限出了问题. 关闭Mysql /usr/local/mysql/support-files/m ...

  5. [其他]win7下chrome浏览器插件导出与导入

    下载了某些插件,重装电脑怎么不备份,重装之后怎么再次使用,一文搞定! 导出crx格式备份文件 1.选择 自定义格式及控制 > 更多工具 > 扩展程序: 2.勾选"开发者模式&qu ...

  6. WinForm 布局,容器、打印和对话框控件

    今天,我主要学习了容器控件.打印控件.对话框控件. 在正式进行今天的内容之前,首先补充了布局的两个属性:Anchor:锁定位置,Dock:填充位置,一般与容器控件配合使用. 之后,我学习了第一部分内容 ...

  7. python2与python3

    一.print python2 print  "hello world !" python3 print("hello world!") 二.字符编码 pyth ...

  8. 非root用户搭建hadoop伪分布式

    0.安装软件列表 jdk-7u25-linux-x64.tar.gz hadoop-2.5.0.tar.gz hadoop-native-64-2.5.0.tar   1.准备Linux环境(root ...

  9. jquery正则常用的

    jQuery.validator.addMethod("mobilePhone",function(value,element){ return this.optional(ele ...

  10. UI_APPEARANCE_SELECTOR 延伸

    iOS后属性带UI_APPEARANCE_SELECTOR 可以统一设置全局作用 例如: 1>开关控件 @property(nullable, nonatomic, strong) UIColo ...