get()


Returns an item(s) reference.

Syntax
Selectable.get([items])
Notes

The method accepts a single argument in the following forms:

  • HTMLElement - the element node.
  • Number - the index of the selectable element node.
  • Array - an array of element nodes or indexes. You may also pass instances of HTMLCollection or NodeList.

The method returns an Object or an Array of objects of the following format:

{
    node: HTMLElement,        // the element node
    rect: DOMRect,            // the element node's bounding rects
    startselected: Boolean    // item was already selected on mousedown / touchstart
    selected: Boolean,        // item is currently selected
    selecting: Boolean,       // item is currently being selected
    unselecting: Boolean      // item is currently being deselected
}

Examples
Demo
<ul>
    <li class="odd"></li>
    <li class="even"></li>
    <li class="odd"></li>
    <li class="even"></li>
    <li class="odd"></li>
    <li class="even"></li>
    <li class="odd"></li>
    <li class="even"></li>
</ul>
const selectable = new Selectable({ filter: "li" });

// select the first four items
selectable.select([0,1,2,3]);
    selectable.get(0)
    selectable.get([0,2,7])
    selectable.get(document.querySelectorAll(".odd"))
    selectable.get(document.querySelectorAll(".even"))