<div id="a">
<div><div>。。这里有很多div<br></div></div>
</div>
如果一次click
判断  是在div#a 之外 还是 在 div#a 之内
类似于mouseleave,

解决方案 »

  1.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <title>floatDiv2.html</title>
        
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="this is my page">
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <style type="text/css">
            #show {
                border: 1px solid black;
                background-color: #E5F0FB;
                position: absolute; 
                width: 150px;
                height: 100px; 
                display: none;
            }
        </style>
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript">
            $(function () {
                $(document).click(function (e) {
                    if (e.target.id != "show") {
                        $("#show").hide();
                    } 
                });
                $("a").click(function (e) {
                    $("#show").css({left: e.clientX, top: e.clientY}).show();
                    return false;//防止冒泡
                });
            });
        </script>
          </head>
      
      <body>
          <a href="#">click me</a>
        <div id="show"></div>
      </body>
    </html>
    or
    $("div").click(function () {
      jQuery.contains(this, $("#a")[0]);
    });
      

  2.   

    ie用元素的contains()函数
    Firefox下包含以下代码:
    if(typeof(HTMLElement)!="undefined")
      HTMLElement.prototype.contains=function(obj)
      {
        if(obj==this)return true;
        while(obj=obj.parentNode) if(obj==this)return true;
        return false;
      }
      

  3.   

    <script>
    var ac=false;
    </script><div id='a' click='ac=true;'>....</div>最后在吧ac设置为false
      

  4.   

    hookee 很深入啊
    KK3K2005 很简洁