zoukankan      html  css  js  c++  java
  • 父子元素select悬浮代码,兼容火狐

        //公共切换方法
        function SwitchCommon() {
            //悬浮显示
            $(document.body).on("mouseenter", "[hex-eidtstate]", function (event) {
                event.stopPropagation();
                //发布对象特殊处理
                if ($(this).attr("hex-eidtstate") == "publish") {
                    $(this).find(".name").addClass("hide");
                    $(this).find(".panel").removeClass("hide");
                    return false;
                }
                $(this).find(".name").each(function () {
                    if ($(this).hasClass("hide")) {
                        $(this).removeClass("hide");
                    } else {
                        $(this).addClass("hide");
                    }
                })
            })
            $(document.body).on("mouseleave", "[hex-eidtstate]", function (event) {
                event.stopPropagation();
                //发布对象特殊处理
                if ($(this).attr("hex-eidtstate") == "publish") {
                    $(this).find(".panel").addClass("hide");
                    $(this).find(".name").removeClass("hide");
                    return false;
                }
                $(this).find(".name").each(function () {
                    if ($(this).hasClass("hide")) {
                        $(this).removeClass("hide");
                    } else {
                        $(this).addClass("hide");
                    }
                })
            })
        }
        //火狐浏览器增强代码
        function firefoxUpdate() {
            var agentInfo = navigator.userAgent.toLowerCase();
            //如果是'火狐'
            if (agentInfo.indexOf('firefox') > 0) {
                console.log("firefox");
                //对于火狐浏览器,select作为子元素,展示option内容时,会触发父元素的mouseleave,造成无法选中发情况
                $(document.body).on("mouseover", "select", function (event) {
                    event.stopPropagation();
                })
                $(document.body).on("mouseout", "select", function (event) {
                    event.stopPropagation();
                })
                $(document.body).on("change", "select", function (event) {
                    $(this).parents("[hex-eidtstate]").trigger("mouseleave");
                })
            }
        }
  • 相关阅读:
    c# 判断一个ip通不通 能不能ping通
    C#二进制与字符串互转换,十六进制转换为字符串、float、int
    将datagridview数据保为xml或txt文件
    笨办法学Python(九)
    笨办法学Python(八)
    笨办法学Python(七)
    Linux安装 NTFS 支持
    Linux安装中文字体包
    Oracle VM VirtualBox 共享文件夹设置
    Verilog频率计设计
  • 原文地址:https://www.cnblogs.com/sanqianjin/p/8056637.html
Copyright © 2011-2022 走看看