Wait cursor over entire html page

后端 未结 14 1311
离开以前
离开以前 2020-12-02 14:19

Is it possible to set the cursor to \'wait\' on the entire html page in a simple way? The idea is to show the user that something is going on while an ajax call is being com

14条回答
  •  温柔的废话
    2020-12-02 14:53

    Here is a more elaborate solution that does not require external CSS:

    function changeCursor(elem, cursor, decendents) {
        if (!elem) elem=$('body');
    
        // remove all classes starting with changeCursor-
        elem.removeClass (function (index, css) {
            return (css.match (/(^|\s)changeCursor-\S+/g) || []).join(' ');
        });
    
        if (!cursor) return;
    
        if (typeof decendents==='undefined' || decendents===null) decendents=true;
    
        let cname;
    
        if (decendents) {
            cname='changeCursor-Dec-'+cursor;
            if ($('style:contains("'+cname+'")').length < 1) $('