JSFiddle - React, Tailwind, and code Playground
HTML
<body><div id="fixed" class="div-fixed"></div> <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</body>
CSS
.div-fixed {
background-color:#999;
width:100px;
height:100px;
position:fixed;
top:10px;
left:10px;
}
JavaScript
$(function () {
var position = $("#fixed").offset();
$("#fixed").html(position.top);
$(window).scroll(function () {
var position = $("#fixed").offset();
$("#fixed").html(position.top);
});
})