How to change cursor to wait when using jQuery .load()

后端 未结 8 647
孤街浪徒
孤街浪徒 2020-12-08 13:35

While waiting for a response from a .load(), is there any way to change the cursor to the busy/wait cursor?

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-08 13:48

    Change the body's CSS to cursor: progress.

    To do this, just make a "waiting" class with this CSS, and then add/remove the class from the body.

    CSS:

    .waiting {
        cursor: progress;
    }
    

    Then in your JS:

    $('body').addClass('waiting');
    

    You can remove it later with .removeClass.

    • https://developer.mozilla.org/en/CSS/cursor
    • http://api.jquery.com/addClass/
    • http://api.jquery.com/removeClass/

提交回复
热议问题