Skip to content

Instantly share code, notes, and snippets.

@cam-gists
Created August 20, 2012 15:50
Show Gist options
  • Select an option

  • Save cam-gists/3405311 to your computer and use it in GitHub Desktop.

Select an option

Save cam-gists/3405311 to your computer and use it in GitHub Desktop.
JavaScript: Swap Cursor
// cursor to icon
$('#canvas').mouseout(function(){
$('#mycursor').hide();
return false;
});
$('#canvas').mouseenter(function(){
$('#mycursor').show();
return false;
});
$('#canvas').mousemove(function(e){
$('#mycursor').css('left', e.clientX - 20).css('top', e.clientY + 7);
});
///CSS
canvas{cursor: url(../imgs/cursor.png), none;
}
#mycursor {
cursor: none;
width: 97px;
height: 137px;
position: absolute;
display: none;
top: 0;
left: 0;
z-index: 10000;
}
///HTML
<div id="mycursor"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment