在这个示例http://jsfiddle.net/cLkau8e9/5/中我试图获取范围内的所有节点,但函数.getNodes()返回错误,如何?
<b id="bold">
hi
</b>
<div id="root">
<span>
hello
</span>
<i>
John
</i>
</div>
JS
var root_node = document.getElementById("root");
//I must use this function
$( "#root" ).append( $( "#bold" ) );
var bold_node = document.getElementById("bold");
var range = document.createRange();
range.setStart(root_node.firstChild, root_node.firstChild.startOffset);
range.setEnd(bold_node, bold_node.endOffset);
//error "range.getNodes is not a function", why?
var nodes = range.getNodes([3]);