Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

To get the offset values from jquery

Tags:

jquery

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

like image 584
praveenjayapal Avatar asked Jun 25 '09 07:06

praveenjayapal


People also ask

What is offset () Top?

The offsetTop property returns the top position (in pixels) relative to the parent. The returned value includes: the top position, and margin of the element. the top padding, scrollbar and border of the parent.

How do I get Offsetbottom?

In the above code, the “div” element is created for which the offset bottom is calculating once the button is clicked. The offset bottom is calculating by using this statement “var bottom = el. offsetTop + $(el). outerHeight();” and calculated value is displaying by the alert, as we can see in the output.

What is offset parent in jQuery?

The offsetParent() method returns the first positioned parent element. Tip: An element can be positioned with jQuery, or with the CSS position property (relative, absolute, or fixed).

What is the difference between position and offset in jQuery?

The offset() method in jQuery returns the first found position of HTML element with respect to the document. The position() method in jQuery returns the current position of HTML element with respect to its offset parent. The jQuery UI offset() is relative to the document.


1 Answers

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..

like image 128
rahul Avatar answered Nov 15 '22 06:11

rahul