Skip to content

Selector Helpers

A set of functions that assist in complex element selections.

Installation

Terminal
pnpm add @mvps-genesis/selector-helpers

Example Usage

.js

import {
    getAbsoluteParent,
    getNextSibling,
    getParent,
    getPreviousSibling
} from '@mvps-genesis/selector-helpers';

// Get the highest level parent matching the selector
getAbsoluteParent(element, '.my-selector');

// Get the next sibling matching the selector
getNextSibling(element, '.my-selector');

// Get the closest parent matching the selector
getParent(element, '.my-selector');

// Get the previous sibling  matching the selector
getPreviousSibling(element, '.my-selector');