zoukankan      html  css  js  c++  java
  • 自己写的一个jquery 弹出层控制插件

    效果如下: 当鼠标移动到版主管理,显示用户管理层,位置为其下方,鼠标从该层上方移走,该层隐藏。

    jquery 类:

    代码
    /*
    * layercontrol 1.0
    * Copyright (c) 2010
    * Date: 2010-08-27
    * 层控制
    */

    (
    function($) {
    $.fn.layercontrol
    = function(options) {
    var defaults = {
    openlayerObj: options
    //隐藏层对象
    }
    var options = $.extend(defaults, options);
    this.each(function() {
    var Obj = $(this);
    $(Obj).bind(
    "mouseover", function(e) {
    var offset = $(e.target).offset();
    offset.top
    += $(this).height();
    $(
    "#" + options.openlayerObj).css(offset).show();
    // $("#" + options.openlayerObj).focus();
    // $("#ShowInfo").focus();
    // void (0);
    });
    $(
    "#" + options.openlayerObj).bind("mouseout", function(e) {
    $(
    this).css('display', 'none')
    });
    $(
    "#" + options.openlayerObj).bind("mouseover", function(e) {
    $(
    this).css('display', 'block')
    });
    // $("#" + options.openlayerObj).bind("blur", function(e) {
    //
    // $(this).css('display', 'none')
    // });
    });
    };
    })(jQuery);

    html 页面使用方法:

    代码
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title></title>

    <script src="../js/jquery-1.3.2.js" type="text/javascript"></script>

    <script src="../js/layercontrol.js" type="text/javascript"></script>

    <script type="text/javascript">
    $(document).ready(
    function() {
    $(
    "#base").layercontrol("openwindow");
    $(
    "#Div1").layercontrol("openwindow");
    });
    </script>

    </head>
    <body>
    <div id="base" style=" 100px; height: 20px; margin-top: 150px; background-color: Red;">
    信息管理
    </div>
    <div id="Div1" style=" 150px; height: 150px; margin-top: 600px; background-color: blue;">
    laldlfsaldflsadf
    </div>
    <div id="openwindow" style="position: absolute; 80px; height: 80px; background-color: Green;">
    跟随的idv
    </div>
    </body>
    </html>

     这边有个问题:如果想控制的方式为:不是从该层上移走隐藏,而是在弹出层之外的地方点击隐藏,大家有什么好的实现办法?

  • 相关阅读:
    app store 上架流程
    iOS代码规范
    【转】clang warning 警告清单(备查,建议直接command + F 速查 )
    计算文字的高度和宽度--以微博会话界面中用户名(userName)为例
    找树节点在二叉树中的深度
    partition函数两种实现方法
    《剑指offer》19题自己实现求普通二叉树的镜像
    删除文件就弹出对话框“不能完成此操作,因为找不到一个或多个需要的项目。(错误代码 -43)
    IntelliJ IDEA快捷键
    idea for mac 最全快捷键整理
  • 原文地址:https://www.cnblogs.com/dooom/p/1810647.html
Copyright © 2011-2022 走看看