title: Highlight text range using JavaScript
body: <p>I would like to highlight (apply css to) a certain text range, denoted by its start and end position. This is more diffucult than it seems, since there may be other tags within the text, that need to be ignored.</p>
  
  <p>Example:</p>
  
  <pre><code>&lt;div&gt;abcd&lt;em&gt;efg&lt;/em&gt;hij&lt;/div&gt;
  </code></pre>
  
  <p><code>highlight(2, 6)</code> needs to highlight <code>"cdef</code>" without removing the  tag.</p>
  
  <p>I have tried already using a TextRange object, but without success.</p>
  
  <p>Thanks in advance!</p>