How to get nodes lying inside a range with javascript?

后端 未结 9 2094
被撕碎了的回忆
被撕碎了的回忆 2020-11-29 03:59

I\'m trying to get all the DOM nodes that are within a range object, what\'s the best way to do this?

var selection = window.getSelection(); //what the user          


        
9条回答
  •  萌比男神i
    2020-11-29 04:48

    bob. the function only returns the startNode and endNode. the nodes in between do not get pushed to the array.

    seems the while loop returns null on getNextNode() hence that block never gets executed.

提交回复
热议问题