zoukankan      html  css  js  c++  java
  • 关于如何用Jquery监听鼠标滚轮改变横向滚动条

    $(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("你点击了右键");
    
         }
    
         });
    
         });
  • 相关阅读:
    springboot整合mybatis 异常 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
    报时助手
    Huffman树费用
    动画效果
    工具和其他操作
    使用筛选器获取元素
    DOM操作
    属性和样式操作
    jQuery基础
    选择器
  • 原文地址:https://www.cnblogs.com/woleicom/p/4058561.html
Copyright © 2011-2022 走看看