Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Select elements by class or id or tag
JavaScript
Tag: v0.2.0

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
test
.gitignore
.testem.json
LICENCE
README.md
class.js
id.js
index.js
name.js
package.json
query.js
queryAll.js
tag.js

README.md

by

Select elements by class or id or tag

Example

Because document.getElementsByClassName is simply too verbose.

Also these functions return arrays! You can also pass an optional first parameter to give it a different context then document.

var byClass = require("by/class")
    , queryAll = require("by/queryAll")

var elems = byClass("some-class")

var other = queryAll(elems[0], ".some div.selector")

Also has

  • var byName = require("by/name") which is short for document.getElementsByName
  • var byId = require("by/id") which is short for document.getElementById
  • var query = require("by/query") which is short for document.querySelector
  • var queryAll = require("by/queryAll") which is short for document.querySelectorAll
  • var byTag = require("by/tag") which is short for document.getElementsByTagName

Installation

npm install by

Contributors

  • Raynos

MIT Licenced

Something went wrong with that request. Please try again.