getNextElement
Commons
stable
Finds the next or previous focusable HTML element in a flat list relative to the currently focused element, with an optional visibility/condition filter.
API
Signature
Signature TypeScript complète, extraite du fichier util.
API
Paramètres
Paramètres d'entrée acceptés par cet util.
- elementsrequisArray<HTMLElement>
- The flat array of elements to traverse (e.g. all focusable children in a list).
- location'next' | 'prev'
- Direction of traversal. 'next' moves forward; 'prev' moves backward. Defaults to 'prev'.
- condition(el: HTMLElement) => boolean
- Optional guard predicate. An element that returns false is skipped. Elements with offsetParent === null (hidden) are always skipped.
API
Valeur de retour
La valeur retournée par cet util.
- The next matching element, or undefined when the boundary of the list is reached.
Usage
Exemples
Extraits de code prêts à coller.
Keyboard navigation in a list