domquery

Handy jQuery-like DOM Programming Library

npm install domquery
26 downloads in the last week
79 downloads in the last month

domquery

Minimalistic jQuery-like DOM programming library for compact library & component distributions.

dom = require('domquery')

dom('ul li.fruit')
  .style('background-color', 'red') // or { 'background-color': 'red' }
  .attr('data-foo', 'bar')
  .click(onClickFruit) // or: on('click', onClickFruit)
  .addClass('open')
  .add('<h1>{title}</h1>{content}', { title: 'Hello', content: 'lorem ipsum' })
  .on('click', function () { alert('clicked <ul>'); })
  .on('click li', function () { alert('clicked <li>') })
  .show()

Keyboard events:

dom('<input />')
  .on('> ctrl alt space', function(element, event){ alert('hello!'); })
  .insert('body');

See full API below and tests for more docs.

Install

$ npm install domquery

Or:

$ wget https://raw.github.com/azer/domquery/master/dist/domquery.min.js
<script src="domquery.min.js"></script>
<script>
  query('.fruit').style('color', 'red').show()
</script>

API

  • attr
  • html
  • text
  • val

Element methods:

  • add
  • addBefore
  • replace
  • remove

Class methods:

  • addClass
  • hasClass
  • removeClass
  • toggleClass

CSS Methods

  • show
  • style
  • hide

Event methods:

  • off
  • on
  • change
  • click
  • keydown
  • keyup
  • keypress
  • mousedown
  • mouseover
  • mouseup
  • resize

Manuals

domquery is based on following libraries. check out their manuals for detailed info:

Testing

Run:

$ npm test

And visit localhost:7559.

npm loves you