3

How I can change the cursor CSS property of a link element, so when the user click on that link, the cursor switches from pointer to wait?

jQuery(document).ready(function(){
  jQuery('a.cursor_wait').click(function(){
    jQuery('body').css('cursor', 'wait');
  });
});

This works, but I must move with the mouse from the link to see the wait indicator, when I leave my cursor on the link, I still see the pointer.

How can I make this work without moving my cursor?

5 Answers 5

1

Example

http://jsfiddle.net/loktar/3WLGt/4/

JS

jQuery(document).ready(function(){
  jQuery('a.cursor_wait').click(function(){
    jQuery('body').css('cursor', 'wait');
      jQuery(this).css('cursor', 'wait');
  });
});

Changes the property of the current link to the wait cursor as well, because by default they are set to pointer.

Sign up to request clarification or add additional context in comments.

1 Comment

Chromium, trunk: still doesn't work without moving the cursor.
1

you want only wait cursor on your link? so why select body and change cursor?!

$('a').css('cursor','wait');

Comments

0

Try this (not tested) :

jQuery('body').trigger('hover');

Comments

0

if I understand correctly , you want click on a link ( for example DELETE an item ) then change the courser to wait until your request will be done, turn it back to default...

var c= confirm("Are you sure?");
if(c)
{ 
    document.body.style.cursor="wait";
    $.post("delete.php?id=212",function(data){
        alert('I\'ve done it...');
        document.body.style.cursor="default";
    });
} 

Comments

0

I got it to work changing the class of the a, and changing the jquery to $ as below:

$(document).ready(function() {
    $('a').click(function() {
        $('body').css('cursor', 'wait');
        $(this).css('cursor', 'wait');
    });
});

However, this will work for all anchor tags a. You will need to specify the css class you want it to apply to.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.