Xavier Xavier - 6 months ago 129
Javascript Question

get right position of Element? jQuery or javascript

I wish to get the right position of an element in jquery, i have tried

attr('right')
, and i have read the API document regarding
.position().right
which is non existent (i believe).

http://jsfiddle.net/xavi3r/vcuq7/

Is an example i wish to alert the right value for.

Answer

You want to find the value of the CSS right property?

$('#foo').css('right');

In plain Javascript:

document.getElementById('foo').style.right;

But, if you want to find the calculated distance from the right edge of an element to the right edge of another one, then you'll have to do that yourself, combining .position().left and .offsetWidth

Comments