<!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>无标题文档</title>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript"> 
$(document).ready(function(){
  $(".flip").mouseover(function(){
    $(".panel").slideDown("slow");
  });
  $(".flip").mouseout(function(){
    $(".panel").slideUp("slow");
  });
});
</script>
 
<style type="text/css"> 
div.panel,p.flip
{margin:0px;
padding:5px;
text-align:center;
background:#e5eecc;
border:solid 1px #c3c3c3;
}
div.panel
{height:120px;
display:none;
}
</style>
 
<body><p class="flip">滑过这里</p>
<div class="panel">
<p>11111111111111111</p>
<p>2222222222222222222222</p>
</div></body>
</html>请问下 当我 鼠标移入p div显示出来了 而我想把鼠标也移入div里面 可是我这个当鼠标移出p的时候 div也消失了

解决方案 »

  1.   

    $(document).ready(function(){
      var timer;
      $(".flip").mouseover(function(){
        $(".panel").slideDown("slow");
      });
      $(".flip").mouseout(function(){
        timer = setTimeout(function(){
            $(".panel").slideUp("slow");
        },100);
      });
       $(".panel").mouseover(function(){
           if(timer) clearTimeout(timer);
       }).mouseout(function(){
           $(".panel").slideUp("slow");
       });
    });
      

  2.   

    只用css样式就可以了<!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>无标题文档</title>
    <style type="text/css"> 
    .flip
    {
    margin:0px;
    padding:5px;
    text-align:center;
    background:#e5eecc;
    border:solid 1px #c3c3c3;
    }
    .panel
    {
    margin:0px;
    padding:5px;
    text-align:center;
    background:#e5eecc;
    border-top:solid 1px #c3c3c3;
    }
    .panel
    {
    height:120px;
    display:none;
    }
    .flip:hover .panel
    {
    display:block;
    }
    </style>
     
    <body><div class="flip">滑过这里
    <div class="panel">
    <p>11111111111111111</p>
    <p>2222222222222222222222</p>
    </div>
    </div>
    </body>
    </html>
      

  3.   

    html标准规定,div是不能写在p里面的,要把p也改成div
      

  4.   


    <!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>无标题文档</title>
    <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
    <script type="text/javascript"> 
    $(document).ready(function(){
      $(".flip").mouseover(function(){
        $(".panel").slideDown("slow");
      });
      $("#content").mouseleave(function(){
        $(".panel").slideUp("slow");
      });
    });
    </script>
      
    <style type="text/css"> 
    div.panel,p.flip
    {
     
    margin:0px;
    padding:5px;
    text-align:center;
    background:#e5eecc;
    border:solid 1px #c3c3c3;
    }
    div.panel
    {
     
    height:120px;
    display:none;
    }
    </style>
      
    <body>
     <div id="content" style="display:inline-block;width:100%">
    <p class="flip">滑过这里</p>
    <div class="panel">
    <p>11111111111111111</p>
    <p>2222222222222222222222</p>
    </div>
     </div>
    </body>
    </html>
      

  5.   


    这个试过了 不行的
    看了楼下的  貌似是这样的 
    把p也换成div试试
    或者在p外面套个div  把事件绑在外面的div