↑
Main Page
setStartBefore
Figure 10-2
Several methods help you get more specific with selections while still setting these properties for you.
These are the following:
?
setStartBefore(
refNode
)
— Sets the starting point of the range to begin before
refNode
(so
refNode
is the first node in the selection). The
startContainer
property is set to
refNode
’s
parent and the
startOffset
property is set to the index of
refNode
within its parent’s
childNodes
collection.
?
setStartAfter(
refNode
)
— Sets the starting point of the range to begin after
refNode
(so
refNode
is not part of the selection; rather, its next sibling is the first node in the selection). The
startContainer
property is set to
refNode
’s parent and the
startOffset
property is set to
the index of
refNode
within its parent’s
childNodes
collection plus one.
?
setEndBefore(
refNode
)
— Sets the ending point of the range to begin before
refNode
(so
refNode
is not part of the selection; its previous sibling is the last node in the selection). The
endContainer
property is set to
refNode
’s parent and the
endOffset
property is set to the
index of
refNode
within its parent’s
childNodes
collection.
321
Advanced DOM Techniques
13_579088 ch10.qxd 3/28/05 11:39 AM Page 321
Free JavaScript Editor
Ajax Editor
©
→