concurrent execution of event handlers in jquery -
i have horizontal menu in website, , each item in menu have image , sub menu.i write event handler hover. should hide visible sub menu , images before show right image menu. problem when switch between 2 menus rapidly first 1 become visible after handler second 1 execute hide images. , result both images become visible. mess! here code , need prevent execution of function before fadein or slidedown completed. here js code:
$(function() { $("#primary-menu li").hover(function(){ if($("#image-menu-"+mlid).is(":visible")) return // hide previous image $("#sub-menu div").hide() $('#menu-image img').hide(); var attr = $(this).attr('class'); var mlid = attr.substr('5'); var index = $("#primary-menu li").index(this); $("#image-menu-"+mlid).fadein(600); if($("#div-"+mlid).length) $("#div-"+mlid).slidedown('fast'); }); });
delay should trick, there examples on @ website.
Comments
Post a Comment