How to get right position of Element?

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


It looks to me that this works:

jQuery('#elem').offset().left + jQuery('#elem').width() 

Fiddle: http://jsfiddle.net/adamovic/fcyL5sg0/


$(document).width() - ($('#elem').offset().left + $('#elem').width());

should get you the space on the right side of the element which you can then set as the value for the 'right' property of the element's position;