Index returns the position of the first element within the Selection object relative to its sibling elements.
()
| 80 | // Index returns the position of the first element within the Selection object |
| 81 | // relative to its sibling elements. |
| 82 | func (s *Selection) Index() int { |
| 83 | if len(s.Nodes) > 0 { |
| 84 | i := 0 |
| 85 | for n := s.Nodes[0].PrevSibling; n != nil; n = n.PrevSibling { |
| 86 | if n.Type == html.ElementNode { |
| 87 | i++ |
| 88 | } |
| 89 | } |
| 90 | return i |
| 91 | } |
| 92 | return -1 |
| 93 | } |
| 94 | |
| 95 | // IndexSelector returns the position of the first element within the |
| 96 | // Selection object relative to the elements matched by the selector, or -1 if |
no outgoing calls