npm.io
0.0.1 • Published 10 years ago

jshit

Licence
MIT
Version
0.0.1
Deps
0
Vulns
0
Weekly
0

jShit

WIP. The last library for dirty DOM manipulations if you can avoid that.

Install

First:

npm install jshit --save

Then:

// using CommonJS and Webpack with babel-loader
import { $, $, dom } from 'jshit'

// loaded directly from CDN
// $/$/dom ... will be automatically exposed as global vars.

API

Selector
// for a single dom element
$('elmement')

// for a dom array
$('elemements')

// remember that $/$ is just a shorthand
// for document.querySelector/querySelectorAll
// .find is a short hand for querySelectors in its parent element
// it works for `dom` function set globally by jShit
var el = dom($('element'))
el.find('li')
// return something like : DOM {el: NodeList[5]}
// which is your `li` array

Loop

// if you got a dom array using $
// for using dom.find() method
// you can iterate over each dom element
var els = dom($('element')).find('li')
els.each(function (el, index) {
  console.log(el, index)
})

License

MIT.