Trigger 'dummy' mouse wheel event

前端 未结 9 1027
隐瞒了意图╮
隐瞒了意图╮ 2021-01-03 22:30

Is there a way to trigger a scroll wheel event with an arbitrary delta. Just like jQuery does with \'click\' like:

$(\'#selector\').trigger(\'click\');
         


        
9条回答
  •  灰色年华
    2021-01-03 23:07

    Hi you can do that by adding a event listener. I have searched for the same and got the below code snippet and it is working. check you have the same requirement


    
    
    Mouse Scroll Wheel example in JavaScript
     
     
    
    
    Scroll mouse wheel to move this DIV up and down.
    
    Event Affect
    ------------------------------------------------------------

    based on the delta variable you can write your own custom functionality.

    In html 5 mouse scroll event is being handled you can try in that way also

提交回复
热议问题