tags:

views:

602

answers:

2

Hi friends,

How do i find the offset value of an image, which is enclosed with in a table. The table consist of lot of images. i want to get the offset - left, right, top, bottom for all the image while hover into the image. I need this in jquery

Thanks,
Praveen J

+2  A: 
var elem = $("your_element");
var offset = elem.offset();
var leftValue = offset.left;
var topValue =  offset.top;

To get right and bottom values add width and height values to left and top..

rahul
+1  A: 

Please read the jQuery documentation. These functions are all very clearly spelled out.

$("#yourImg").bind("mousemove", function(e) {
    var $this = $(this);
    var imgLeft = e.pageX - $this.offset().left;
    var imgTop = e.pageY - $this.offset().top;
    var imgBottom = $this.offset().top + $this.height() - e.pageY;
    var imgRight = $this.offset().left + $this.width() - e.pageX;

    // do more stuff here
}
Jeff Meatball Yang