views:

60

answers:

2

I have the following event handler for my html element

jQuery("#seek-bar").click(function(e){
    var x = e.pageX - e.target.offsetLeft;
    alert(x);    
});

I need to find the position of the mouse on the #seek-bar at the time of clicking. I would have thought the above code should work, but it gives incorrect result

A: 

Try this:

jQuery(document).ready(function(){
   $("#special").click(function(e){
      $('#status2').html(e.pageX +', '+ e.pageY);
   }); 
})

Here you can find more info with DEMO

Krunal
+2  A: 
Ninja Dude
+1 for the examples...one note though I'd also add the code here, if your link dies this question becomes useless in the future, I'd put the code for each and a brief description here :)
Nick Craver
oh, sorry Nick! I haven't thought about it. Sure I'm going to post my code and description too in few minutes. Thanks for informing. Have a Good Day !
Ninja Dude