Skip to content


Changing the cursor on web pages

I’m getting more into jQuery and I recently ran into a need to change the mouse cursor when I would hover over a section to indicate what’s going on.

The first thing I needed was a cursor type. I accomplished this by adding a quick class entry into my CSS file:

.over {
cursor: pointer;
}

I used the pointer cursor because that’s what I needed. I came across a really awesome CSS cursor compatibility list at:
http://www.quirksmode.org/css/cursor.html

The next step was to add Javascript to handle the mouse over:

$(document).ready(function(){

$('.mybox').mouseover(function() {
$(this).addClass("over");
});

$('.mybox').mouseout(function() {
$(this).removeClass("over");
});

});

Basically the div section I used was:

<div class="mybox">Change the cursor</div>

Now I have a pointer when I hover over the div section.

Posted in Web.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.