Skip Navigation Links



Find Screen Coordinates of Mouse using jQuery

Author : Virendra Dugar      Blog :jQuery By Example      Date: 7/24/2012 5:30:00 AM


In this post, you will see how to find the screen coordinates of the location where mouse button is pressed or suppose there is an image on your web page and you want to display the screen coordinates of the location where the mouse button is pressed on the image.

To find out screen coordinates, we can use event object's 2 properties.

ScreenX: The screenX event attribute returns the horizontal coordinate (according to the users computer screen) of the mouse pointer when an event was triggered.

ScreenY: The screenY event attribute returns the vertical coordinate (according to the users computer screen) of the mouse pointer when an event was triggered.

$(document).ready(function() {
   $('img').mousedown(function(e) {
      var sMsg = '<u>Coordinates:</u><br/>';
      $('p').html(sMsg + 'Horizontal: ' + e.screenX + ', Vertical: ' + e.screenY);
   });
});​
See result below.(Click on image)


See Complete Code
Feel free to contact me for any help related to jQuery, I will gladly help you.

Bloggers

active bloggers in the last 24 hrs. Number shown in the bracket represents number of posts published in past 24 hrs,


other authors(71)

sankarshan(11)

Milind(10)

palsworld(3)

AMJAD KHAN(2)

Fidarose Isha(2)

Firoze Shakir Photographerno1(2)

Harshil(2)

Jaspreet(2)

kannaji e(2)

Nish(2)

R.D. Bhalekar(2)

Sree(2)

Srinivasan Sampathkumar(2)

Sunthosh Kumar(2)

The Guy in the Hat ™(2)

Vasudev Ram(2)

vskesavarao(2)

--- :) ----(1)

Aarthi(1)

Abha Iyengar(1)

Abhishek Mukherjee(1)

Abrachan Pudussery(1)

Abraham Tharakan(1)

Aditya Tibrewala(1)

admin(1)

Always Happy(1)

Amar Ashok Jajoo(1)

anouradha bakshi(1)

Anu Varma(1)

Archana Kumar(1)

aseemrastogi2(1)

Bhushavali N(1)

Biswa Prakash(1)

Champa(1)

CM(1)

Creativity(1)

Cynthia Z(1)

dawdayogesh(1)

Debolina Raja Gupta(1)

Deeps(1)

Dimple Maheshwari(1)

Disha(1)

Everything(1)

Evita Seema DCunha(1)

Govind Kumar(1)

Harimohan(1)

Heena Jain(1)

iBeingMe(1)

Indrani(1)

IS(1)

J P Joshi(1)

Jahn n Style(1)

Jayant(1)

Jigish Shah(1)

k(1)

Kalamwali Bai(1)

Krishna Rao(1)

Kyra(1)

Linuxos4all(1)

Lluvia....(1)

Manoje Nath(1)

Meena(1)

mervin anto(1)

Mohd Salim(1)

MUNZ TDT(1)

NG(1)

Nisheeth Ranjan(1)

Nivedita Thadani(1)

Nivedita Thadani(1)

numerounity(1)

Pari Vasisht(1)

Pheno Menon(1)

pinksocks(1)

pixie(1)

Prahallad Panda(1)

Preety(1)

R-A-J(1)

rajkumar r(1)

Rajlakshmi(1)

Ram Bansal(1)

Ram Surjit(1)

Ranjith(1)

Ray Titus(1)

rm(1)

RNA Corp(1)

RWABhagidari.blogspot.com(1)

Sabina Fatima Hussain(1)

Sadhana Padmanabhan(1)

Sankara Subramanian(1)

Saravanan Sivaraman(1)

Saro(1)

sayedkhadri(1)

Shankha(1)

Shiva(1)

Shobhaa De(1)

sidhu352(1)

Sneha Sharma(1)

Sonal(1)

soraya nulliah(1)

Sriram Khé(1)

Srividya Ram(1)

sumana Mukhopadhyay(1)

Susan Deborah(1)

swapnil kochetaa(1)

Tarang Sinha(1)

TCYonline.com(1)

Umasree(1)

Vidya Sury(1)

vishesh unni raghunathan(1)

wildflower(1)


garland of Languages of India
an amalgamation of the diversified traditions
gracefully presented with novelty
http://www.haaram.com