I'm looking for a pure JS way of finding the offset of a child within it's parent.
Given the below sample:
<div> A <br> short space elapsed, <b>and</b> up into this noiselessness came Ahab alone from his cabin. <span>Taking a few turns on the quarter-deck, he paused to gaze over the side</span> </div> I would get 3 children, a br, b, and span. Each would need to have an offset to the start of the div - So the index of how many characters into the div the start of the tag is.
So the br would have an offset of 2.
My initial idea was to get all the children of the div, then somehow from that be able to easily get an index.
offset of 2- 2px, 2em, 2cm...? Why 2?<br/>is not visible, how you see that offset? Is your offset same as padding/margin? What offset would be for any other childs?