zoukankan      html  css  js  c++  java
  • js 右击事件

    一、该方法无法获取$(this)

    $.fn.extend({
            "rightclick": function (fn) {
                $(this).mousedown(function (e) {
                    if (e.which === 3) {
                        $(this).bind("contextmenu", function (e) {
                            return false;
                        });
                        fn(e);
                    }
                });
                return this;
            });

    二、该方法可以获取$(this)

     $.fn.extend({
            "rightclick": function (fn) {
                 return this.mousedown(function (event) {
                     if (event.which === 3) {
                         $(this).bind("contextmenu", function (e) {
                             return false;
                         });
                         return fn.apply(this, arguments) || false;
                     }
                 });

    });

  • 相关阅读:
    网络基础
    Web开发几种常用工具
    win组合键概述(windows10)
    Alfred使用
    Java8之新特性--modules
    jsp九大内置对象和四大作用域
    authtype
    Myeclipse中的快捷键
    如何在Jenkins CI 里调试
    写好unit test的建议和例子
  • 原文地址:https://www.cnblogs.com/johnblogs/p/10239035.html
Copyright © 2011-2022 走看看