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

Pin It


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

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

Twitter

  • May 2, 2012 04:15

    10 Free WordPress Theme To Make You Forget About Premium Theme http://t.co/YRiLCiVa

  • March 2, 2012 17:16

    3 Helpful Tools to Test Cross Browser Compatibility of Webpage http://t.co/FY0jh8Dn

  • March 2, 2012 16:43

    3 Helpful Tools to Test Cross Browser Compatibility of Webpage http://t.co/QUlYKInf #IE #FF #Chrome #Testing #CrossBrowser

  • March 2, 2012 12:52

    Top 5 Plugins to Build Contact Form for WordPress http://t.co/PWyR08Iq #WordPress #Plugins #ContactForm

  • June 11, 2011 02:49

    CSS 3 Transitions http://bit.ly/m0pK3t

Design Gala © 2012 All Rights Reserved

Designed by 76miles

Powered by WordPress

More in jQuery (10 of 18 articles)
treeview