ThunderChicken
ThunderChicken

Reputation: 15

I want to change the cursor to wait then back to default after the click event happens

I have an anchor tag when click it activates a function to bring in some database. But while the database is loading I would like to show the wait cursor then back to default cursor when the database is loaded.

I have this code:

$(document).ready(function () {
    $('a').click(function() {
        $('*').css("cursor", "progress");
    });
});

but what it does is replace the cursor all time when the "a" tag is lcicked

Upvotes: 1

Views: 73

Answers (1)

Scimonster
Scimonster

Reputation: 33399

When the function completes, you can reset the cursor.

$(document).ready(function () {
    $('a').click(function() {
        $('*').css("cursor", "progress");
        $.get('your api call', function(response){
            // do something with response
            $('*').css("cursor", "auto");
        });
    });
});

However, instead of applying the CSS cursor to all elements, you should just do it on the top-level <html> element. It should be a lot faster.

$('html').css("cursor", "progress");

Upvotes: 1

Related Questions