1.0.5 • Published 6 years ago
crabby-grab v1.0.5
crabby-grab
Shorthands for referencing elements 🦀
Installation
crabby-grab can easily be installed with npm.
npm i --save crabby-grabUsage
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-grabpackage
grab.version();
// no equivalent