I'm looking for a way to get the offset relative to the whole document for a given node with Javascript. Eg.:
<html>
<head></head>
<body>
<div id="mainContent">
<h1 id="myTitle">Title</h1>
<p>First paragraph</p>
<p>Second <b>paragraph</b></p>
</div>
</body>
</html>
Then (using JQuery):
$("#myTitle").getDocumentOffset()
should return 47 because the h1 with id myTitle starts at offset 47 in characters relative to the whole document.
Any idea how to accomplish this?
Thanks in advance.