Eq reduces the set of matched elements to the one at the specified index. If a negative index is given, it counts backwards starting at the end of the set. It returns a new Selection object, and an empty Selection object if the index is invalid.
(index int)
| 33 | // set. It returns a new Selection object, and an empty Selection object if the |
| 34 | // index is invalid. |
| 35 | func (s *Selection) Eq(index int) *Selection { |
| 36 | if index < 0 { |
| 37 | index += len(s.Nodes) |
| 38 | } |
| 39 | |
| 40 | if index >= len(s.Nodes) || index < 0 { |
| 41 | return pushStack(s, nil) |
| 42 | } |
| 43 | |
| 44 | return s.Slice(index, index+1) |
| 45 | } |
| 46 | |
| 47 | // Slice reduces the set of matched elements to a subset specified by a range |
| 48 | // of indices. The start index is 0-based and indicates the index of the first |