MCPcopy Create free account
hub / github.com/PuerkitoBio/goquery / Index

Method Index

array.go:82–93  ·  view source on GitHub ↗

Index returns the position of the first element within the Selection object relative to its sibling elements.

()

Source from the content-addressed store, hash-verified

80// Index returns the position of the first element within the Selection object
81// relative to its sibling elements.
82func (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

Callers 3

TestNbspFunction · 0.80
TestIndexFunction · 0.80
BenchmarkIndexFunction · 0.80

Calls

no outgoing calls

Tested by 3

TestNbspFunction · 0.64
TestIndexFunction · 0.64
BenchmarkIndexFunction · 0.64