zoukankan      html  css  js  c++  java
  • 关于鼠标点击其他地方隐藏层的实例(要引入jquery包哦)

    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>test</title>
    <style  type="text/css">
    .div_d{ padding:10px; border:1px dotted red; position:absolute; display:none; cursor:pointer;}
    </style>
    <script src="jquery-1.2.6.min.js"></script>
    <script type="text/javascript">
    $(function(){
               $("input[id=search]").focus(function(even){                                               
                                         var pos=$(this).offset();
                                       
                                         $(".div_d").css({left:pos.left,top:pos.top+20+"px",display:"block"});
                                         });
                document.onclick=function(e){
         
                       var e=e?e:window.event;
                       var tar = e.srcElement||e.target;
                       if(tar.id!="search"){
                           if($(tar).attr("class")=="div_d"){
                               $(".div_d").css("display","block")
                           }else{
                               $(".div_d").css("display","none");
                           }
                       }
                     }
               })

    </script>
    </head>

    <body style=" padding-left:300px;">
    <input id="search" />
    <div class="div_d">  <a href="http://www.baidu.com" target="_blank">ldksjfla</a>;sdflaks;djf;lkasdjfl;kja;lsdk</div>
    </body>
    </html>

  • 相关阅读:
    遗传学详解及Matlab算法实现
    (转)非常好的理解遗传算法的例子
    Halcon学习笔记之支持向量机(二)
    Hough 变换
    主元分析PCA理论分析及应用
    Retinex图像增强算法
    Halcon学习笔记之支持向量机(一)
    阿里云OSS安装使用问题
    JS中双击和单击事件冲突解决
    JavaScript正则表达式应用---replace()
  • 原文地址:https://www.cnblogs.com/EWall/p/1942564.html
Copyright © 2011-2022 走看看