Java脚本getSelection()忽略内部HTML [重复]

现在,我正在尝试在div内获取选择范围。问题:当我有这样的div时:

<div> Lorem <p> ipsum dolor sit amet, <b> consetetur <b> sadipscing elitr, <i>sed</i> diam nonumy eirmod tempor invidunt </p> ut l </div>

and am selecting a area that includes multiple of these inner HTML nodes I get something like this: startOffset: 10, endOffset: 2 instead of startOffset: 10, endOffset: 12.

本质上,我想忽略div内的HTML进行选择。