How to change the mouse cursor on mouseover in jquery

This tutorial shows how to change the mouse cursor on mouseover using jquery.

Create the following html file with the javascript:

<script src=""> var t1;</script>
    <label id="detailsButton" for="basic-url">Details:</label>
   	<div id="detailsContent" >This is the details</div>
<script language="javascript">
	// Hide the details by default
	// Get the value of the number for the demo.
		// Show the details				
	// Change cursor on mouse over
	$('#detailsButton').css('cursor', 'pointer');

function showDetails(){
	// Show details
	$('#detailsContent').show( 1000 );
	// unbind the old event and bind hideDetails

function hideDetails(){
	// Hide the details

	// unbind the old event and bind showDetails

The output will be:

This is the details

The html code contains a label that will be change when the mouse is over it. When it is clicked it will call the showDetails method. When a click event happens we first unbind the click event then bind a new click method, this way we are sure that only one method is called when a click happens.



Recent Comments