jQuery Set Mouse Position (not cursor position)

前端 未结 6 2365
伪装坚强ぢ
伪装坚强ぢ 2020-11-28 12:30

I have a link that, when clicked, I would like it to move the position of the mouse to the right (or anywhere within the viewport, for that matter).

in code it would

相关标签:
6条回答
  • 2020-11-28 12:54

    You could hide the cursor, and show another one at a different place.

    Good to have when moving around in a maze for example. The cursor looks like it's stopped but you will see it again when you move outside the window.

    0 讨论(0)
  • 2020-11-28 12:56

    You map change scroll position that will automatically move your pointer to required position;

    $(document).scrollTop();
    

    For some case, I was required to stay pointer on same checkbox although a button show/hide was causing a bubbling... so I did something like;

    $(document).scrollTop( $(document).scrollTop() + parseInt($('.btn-show-selected-group').outerHeight()) );
    $(document).scrollTop( $(document).scrollTop() - parseInt($('.btn-show-selected-group').outerHeight()) );
    
    0 讨论(0)
  • 2020-11-28 13:00

    As other users already have mentioned, there isn't any mechanism is Javascript to do that. However, you can disable the mouse and implement a cursor to do what you need. Here is a link that explains how. How to implement a custom cursor.

    0 讨论(0)
  • 2020-11-28 13:03

    There's no way to accomplish mouse position change via JavaScript or any Client-Side Script. The only reason for that is not to give a client side script potential for abuse as stated before.

    0 讨论(0)
  • 2020-11-28 13:06

    There is no mechanism for moving the mouse via JavaScript.

    0 讨论(0)
  • 2020-11-28 13:06

    I may be wrong, but I don't think it's possible to move the mouse pointer from client-side script. Given the potential for abuse, I certainly hope it isn't.

    0 讨论(0)
提交回复
热议问题