attr-chooser
select among a list of dom elements with the same attribute
example
First write some html with a chooser
attribute (or whatever you want) on the
items you want to select:
onetwothreefour
Then wire up some browser code:
var choose = 'active' {console;};var elems = document;for var i = 0; i < elemslength; i++;
or you can use attractor:
var scope ={console;};var attr ='x-chooser': 'active'scope;attr;
Compile your browser code with browserify:
$ browserify browser.js > bundle.js
methods
var chooser =
var choosef = chooser(className, cb)
Return a function choosef(elem, attrName)
that you should call on every
element you want to wire up for item selection.
When somebody clicks on an element,
cb(elem, ev, name)
fires with the dom element elem
, the click event ev
,
and the group name
set in the attribute value.
choosef(elem, group)
Create a group based on the group
string for the dom element elem
.
install
With npm do:
npm install attr-chooser
license
MIT