Skip to content

gregwym/choosable

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

choosable

Choosable DOM elements. Forked and modified from component/selectable

Installation

$ component install gregwym/choosable

Example

<ul id="pets">
  <li data-name="tobi">Tobi</li>
  <li data-name="loki">Loki</li>
  <li data-name="jane">Jane</li>
  <li data-name="abby">Abby</li>
</ul>

<script>
  var Choosable = require('choosable');
  var choosable = Choosable('#pets > li');

  choosable.on('change', function(e){
    console.log(e.selected.getAttribute('data-name'));
  });
</script>

API

Choosable(selector, el)

Make elements with the given selector choosable, with optional context el.

Choosable#select(el)

Add the given el to the selection.

Choosable#deselect(el)

Remove the given el from the selection.

License

MIT

About

Choosable DOM elements

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%