JSFiddle - React, Tailwind, and code Playground
by Ian Roberts
HTML
<p>This is a paragraph.</p>
<button>Return the offset coordinates of the p element</button>
JavaScript
$("button").click(function(){
var x=$("p").offset();
var z=$("button").offset();
var $diff= (z.left - (z.left - x.left));
alert("p Left: " + x.left);
alert("button Left: " + z.left);
alert("button z.left minus p x.left: " + (z.left - x.left));
//$("button").css({'position' : 'absolute', 'left' : (z.left - x.left), 'background' : '#333'});
//$("button").css({'position' : 'absolute', 'left' : (z.left - (z.left - x.left)), 'background' : '#333'});
$("button").css({'position' : 'absolute', 'left' : $diff});
});