jquery: menu show at mouseover
$(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');
});
精彩评论