JQuery change cursor to link by link

How can I change the css property of the cursor of a link element, so when the user clicks on this link, the cursor switches from a pointer to a wait?

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

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

How can I do this job without moving the cursor?

+3
source share
5 answers

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, because by default they are set to a pointer.

+1
source

Do you only want to wait for the cursor on your link? so why choose a body and change the cursor ?!

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

( ):

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

, a jquery $, :

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

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

0
source

if I understand correctly, you want to click on the link (for example, DELETE element), and then change the cursor to wait until your request is completed, return it by 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";
    });
} 
0
source

Source: https://habr.com/ru/post/1792567/


All Articles