Reputation: 115
Using jQuery, I would like to change the cursor on page when any key is pressed (for example Ctrl). Simple task, however I can not get make it work... This was my first idea, obviously - does not work:
$(document).on('keydown',function(){
$(document).css('cursor','wait');
});
Any idea what is wrong?
Upvotes: 2
Views: 3328
Reputation: 3389
Think what you want is something like this:
$('body').css('cursor','wait');
You can't apply CSS
to the document
. Also if you wanted to only apply this css to the CTRL
key press you could do:
$(document).on('keydown', function (event) {
if (event.ctrlKey) {
$('body').css('cursor', 'wait');
}
});
Upvotes: 4