leo-cheron / element-index

HTMLElement DOM tree position as a proto function

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Element index

HTMLElement DOM tree position as a proto function.

Installation

npm i element-index --save

Implementation

HTML

<ul>
	<li></li>
	<li></li>
	<li class="is-active"></li>
</ul>

JS

import 'element-index';

document.querySelector('.is-active').index(); // returns 2

About

HTMLElement DOM tree position as a proto function

License:MIT License


Languages

Language:JavaScript 100.0%