Search code examples
rangew3c

W3 Document Object Model Range offsets when having mixed content


If I have a text element with a strong child element within its text. For example:

<p>abcd<strong>ef</strong>gh</p>

What would be the correct end offset value for a range that ends between g and h?


Solution

  • The range's endContainer property would be the text node whose content is "gh" and endOffset property 1.

    Further reading: