Getting the browser cursor from “wait” to “auto” without the user moving the mouse

前端 未结 15 1999
自闭症患者
自闭症患者 2020-11-27 13:49

I use this jQuery code to set the mouse pointer to its busy state (hourglass) during an Ajax call...

$(\'body\').css(\'cursor\', \'wait\');

15条回答
  •  执笔经年
    2020-11-27 14:16

    As of jquery 1.9 you should ajaxStart and ajaxStop to document. They work fine for me in firefox. Have not tested in other browsers.

    In CSS:

    html.busy *
    {
       cursor: wait !important;
    }
    

    In javaScript:

    // Makes the mousecursor show busy during ajax 
    // 
    $( document )
    
       .ajaxStart( function startBusy() { $( 'html' ).addClass   ( 'busy' ) } )     
       .ajaxStop ( function stopBusy () { $( 'html' ).removeClass( 'busy' ) } )
    

提交回复
热议问题