开发者

How to control jquery show hide for each one?

开发者 https://www.devze.com 2023-02-09 12:12 出处:网络
How to control jquery show hide for each one? I want mouseover 111, show Hello1. mouseover 222, show Hello2. mouseover 333, show Hello3. Thanks.

How to control jquery show hide for each one? I want mouseover 111, show Hello 1. mouseover 222, show Hello 2. mouseover 333, show Hello 3. Thanks.

<head>
  <style>
      .menu{ display:none; }
  </style>
  <script src="http://code.jquery.com/jquery-1.5.js"></script>
</head>
<body>
<ul>
    <li>
      <a href="" class="link">111</a>
      <div class="menu">Hello  1</div>
    </li>
    <li>
      <a href="" class="link">222</a>
      <div class="menu">Hello  2</div>
    </li>
    开发者_开发百科<li>
      <a href="" class="link">333</a>
      <div class="menu">Hello  3</div>
    </li>
</ul>      
<script>
$(document).ready(
 function(){
    $(".link").mouseover(function(){
    $(".menu").show(".slow");
    });
    $(".menu").mouseout(function () {
    $(".menu").hide("slow");
    });
});
</script>    
</body>


Try using hover as given below:

 $(document).ready(
     function(){
        $(".link").hover(function(){
        $(this).next().show("slow");
        },function () {
        $(this).next().hide("slow");
        });
    });

Working example @:

http://jsfiddle.net/6hTZR/3/


$(".link").mouseover(function () {
   $(this).closest('li').find('.menu').show('slow');
});

$(".menu").mouseout(function () {
    $(this).hide("slow");
});


Use this $(".menu", this) instead of $(".menu").


Try this:

$(".link").hover(
   function(){
    $(this).next("div.menu").fadeIn("fast");
   },
   function(){
    $(this).next("div.menu").fadeOut("fast"); 
   }
);
0

精彩评论

暂无评论...
验证码 换一张
取 消