Search code examples
javascriptjqueryonscroll

Converting mouseover to on scroll with jQuery


I have a piece of jQuery that works when I have my cursor hovered over the div however I would like to change this so it is trigged "on scroll" instead. Any suggestions??

$('.services-item').mouseover(function(){
        $('.services-item').off('mouseover', servicesHoverAction).on('mouseover', servicesHoverAction);
        //servicesHoverAction();
    });

Solution

  • You should change your code to this:

    $('.services-item').scroll(() => {
            $('.services-item').off('mouseover', servicesHoverAction).on('mouseover', servicesHoverAction);
            //servicesHoverAction();
    });