1.0.5 • Published 5 years ago

crabby-grab v1.0.5

Weekly downloads
9
License
MIT
Repository
github
Last release
5 years ago

crabby-grab

Shorthands for referencing elements 🦀

npm

Installation

crabby-grab can easily be installed with npm.

npm i --save crabby-grab

Usage

First, import the library.

import * as grab from 'crabby-grab';

Then you can use it to grab elements. The list below contains the crabby-grab syntax and then its equivalent in vanilla Javascript to show how shortened it is.

  • Grab n th element from class list
grab.class("classname", n)
document.getElementsByClassName("classname")[n]
  • Grab entire class list
grab.classes("classname")
document.getElementsByClassName("classname")
  • Grab element by id
grab.id("id")
document.getElementById("id")
  • Grab n th element from tag list
grab.tag("tagname", n)
document.getElementsByTagName("tagname")[n]
  • Grab the entire tag list
grab.tags("tagname")
document.getElementById("tagname")
  • Grab the document element
grab.doc()
document.documentElement
  • Grab n th element of query selector
grab.selector("selector", n)
document.querySelectorAll("selector")[n]
  • Grab the entire query selector list
grab.selectors("selector")
document.querySelectorAll("selector")
  • Output the version number of the crabby-grab package
grab.version();
// no equivalent
1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.0

5 years ago