3gwebtrain
3gwebtrain

Reputation: 15293

jquery mouseover and mouseenter calling no.of times - how to fix this?

Hi have a onmouseenter and leave function, but i am not getting proper result from this. once i enter in to 'ul' it display properly, but when i leave the 'ul' it is calling again. how to solve this? i am using this function to make 'dropdown' purpose.

myfunction:

$('ul.select').bind("mouseenter mouseleave",function(){
        $('ul.select ul').stop(1,1).slideToggle('250');
    })

    $('ul.select ul li').on('click', function(){
        var qData = $(this).attr('data-qid');
        var html = $(this).text();
        $('ul.select>li').text(html).attr('data-qid',qData);
        $(this).hide().siblings().show();
        $('ul.select').mouseleave();
    })

thanks.

Upvotes: 1

Views: 109

Answers (1)

Roko C. Buljan
Roko C. Buljan

Reputation: 206028

$('ul.select').on("mouseenter mouseleave",function( e ){
     if(e.type === 'mouseenter'){   
        $(this).find('ul').stop(1).slideDown('250');  
    }else{      // if is mouseleave  // DO SOMETHING          
        $(this).find('ul').stop(1).slideUp('250');
    }
});

demo

Upvotes: 1

Related Questions