cloneRange() creates a new range with the same start/end.collapse(toStart) if toStart=true set end=start, otherwise set start=end, thus collapsing the range.selectNodeContents(node) set range to select the whole node contents.selectNode(node) set range to select the whole node.In all these methods, node can be both a text or element node: for text nodes offset skips that many of characters, while for element nodes that many child nodes. Technically, setStart/setEnd can do anything, but more methods provide more convenience. setEndAfter(node) set end at: right after node.setEndBefore(node) set end at: right before node.setEnd(node, offset) set end at: position offset in node.setStartAfter(node) set start at: right after node.setStartBefore(node) set start at: right before node.setStart(node, offset) set start at: position offset in node.We’ve already seen setStart and setEnd, here are other similar methods. There are many convenient methods to manipulate ranges. commonAncestorContainer – the nearest common ancestor of all nodes within the range,.collapsed – boolean, true if the range starts and ends on the same point (so there’s no content inside the range),.in the example above: first text node inside and 3.endContainer, endOffset – node and offset of the end,.in the example above: first text node inside and 2.startContainer, startOffset – node and offset of the start,.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |