jQuery: How to get X-axis Y-axis value?


Well, it’s terrifically easy to get the x-axis and y-axis value of any point with jQuery. I mean the mouse pointer position. We simply do it with event.pageX and event.pageY.

event.pageX gives the mouse position relative to the left edge of the document. And event.pageY gives the mouse position relative to the top edge of the document.

The following function fetches x and y axis on mousemove over the div content.

$(function(){
	$("#content").mousemove(function(e){
		$("#value").html("x-axis: "+e.pageX+"<br />y-axis: "+e.pageY);
	});
});

View Demo | Download Code

About author
Passionate about Web Technology and Web development. Loves Blogging. Keenly interested in Open Source Technology/Software/Framework.
7 total pingbacks on this post
Submit your comment

Please enter your name

Your name is required

Please enter a valid email address

An email address is required

Please enter your message

Design Gala © 2012 All Rights Reserved

Developed by 76 Miles

Powered by WordPress