Hello World!
This is bold
This is italic
Show Code

(1) Does this case ever happen, that startContainer is TEXT NODE but endContainer is ELEMENT NODE?

(2) Does this case ever happen, that startContainer is ELEMENT NODE but endContainer is TEXT NODE?

Yes (1) happens (but (2) probably wont happen). Suppose the following two sensences

<div>First Line</div>
<div>Second Line</div>

Put the moust pointer just before "Second" and move your mouse up to the first line so the first line is selected.

In this case, startContainer will be TEXT and endContainer will be ELEMENT(div)(endOffset==0)