开发者

jquery: menu show at mouseover

开发者 https://www.devze.com 2023-01-10 18:40 出处:网络
$(document).ready(function () { $(\'img.menu_class\').click(function () { $(\'ul.the_menu\').slideToggle(\'medium\');
$(document).ready(function () {
    $('img.menu_class').click(function () {
    $('ul.the_menu').slideToggle('medium');
    });
    $('.img.m开发者_开发百科enu_class').mouseover(function() {
    $('ul.the_menu').slideToggle('medium');
    });
});

I've added this mouseover, but it doesnt work, only if i click.. What have i done wrong?


You should use mouseenter and mouseleave insted of mouseover because mouseover is triggered every time the pointer moves into the child element and mouseenter only when the pointer moves into the bound element.

$('img.menu_class').bind("mouseenter", function () {
    $('ul.the_menu').slideToggle('medium');
});
$('ul.the_menu').bind("mouseleave", function () {
    $('ul.the_menu').slideToggle('medium');
});
0

精彩评论

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