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");
                })
            }
        }
  • 相关阅读:
    jQuery插件开发全解析(转)
    isMemberOfClass和isKindOfClass之间区别
    NSArray,NSSet,NSDictionary总结 (转)
    NSIndexPath(转)
    Maven在dos窗口中的命令
    JPA概要
    fedora的输入法
    iQQ 学习笔记2 :借助新浪微博输入验证码、远程控制退出
    使用EXCEL制作通用打印模块
    字符串加密解密方法
  • 原文地址:https://www.cnblogs.com/sanqianjin/p/8056637.html
Copyright © 2011-2022 走看看