EvoToolkit - v2.3.0 (Changelog)

getIndex

Returns the index of an element relative to its position within its parent.

Source

Contributors

Luke Harrison

Usage

import fireEvent from './../../../node_modules/evotoolkit/src/js/tools/getIndex.js'; // Activate content element matching a specific tab const myTab = block.querySelectorAll('.js-my-tab'); const content = block.querySelectorAll('.c-tabs__content'); content[this.getIndex(myTab)].classList.add('is-active');