JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html>
<body>
<p> </p>
<p>Here html details</p>
<svg viewBox="0 0 200 200">
<line x1="0" y1="0" x2="100" y2="100" stroke="lightgray" />
</svg>
</body>
</html>
JavaScript
$('line').each(function(){
isSVG = (this.getBBox!==undefined);
console.log('jQuery function : '+$(this).top );
console.log('My function : '+(isSVG ? this.getBoundingClientRect().top+window.pageYOffset : $(this).top ) );
});