如何使更简洁(Jquery)

时间:2011-10-29 03:50:06

标签: jquery

$("li.category-top >ul").hide();

    $(".category-top").mouseover(function(){
        $(this).children("ul").show();
    });
   $(".category-top").mouseleave(function(){
        $(this).children("ul").hide();
    });

2 个答案:

答案 0 :(得分:2)

也许这就是:

$("li.category-top >ul").hide();
$('.category-top').hover(function() {
    $(this).children('ul').toggle();
});

技术演示:http://jsfiddle.net/ambiguous/aKvkb/

参考文献:

答案 1 :(得分:0)

如果您将uls放入css中作为display:none,那么您可以保存隐藏行并进行hover()调用