开发者

Javascript slidedown hover LI

i am having a problem in a hover LI that he hover all the li´s and not the one i have hovering.

html:

<div id="lista">
      <ul>
        <li>
             <a href="开发者_JS百科#">content1</a>
           <div class="slide">hide content1</div>
        </li
       <li>
             <a href="#">content2</a>
           <div class="slide">hide content2</div>
        </li>
      </ul>

    </div>

javascript:

$('#lista li ').hover(function () {
$('.slide').slideDown('slow');
}, function () {
$('.slide').slideUp('fast');
});
});


$('#lista li ').hover(
    function () {
        $(this).children('.slide').slideDown('slow');
    },
    function () {
       $(this).children('.slide').slideDown('slow');
    }
);

Explanation: Each time you hover a #lista li element, you have to refer to its children .slide element . If you just do $('.slide'), it means that you are referring to each .slide element in the whole document ;)


Try .mouseover instead of .hover

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜