An open API service indexing awesome lists of open source software.

https://github.com/component/selectable

Selectable DOM elements
https://github.com/component/selectable

Last synced: 8 months ago
JSON representation

Selectable DOM elements

Awesome Lists containing this project

README

          

# selectable

Selectable DOM elements.

![dom element selection js component](http://i.cloudup.com/iZqb9fzgccE.png)

## Installation

$ component install component/selectable

## Example

```html


  • Tobi

  • Loki

  • Jane

  • Abby

var selectable = require('selectable');
var selection = selectable('#pets > li');

selection.on('change', function(e){
for (var i = 0; i < e.selected.length; i++) {
console.log(e.selected[i].getAttribute('data-name'));
}
});

```

## API

### Selectable(selector, el)

Make elements with the given `selector` selectable, with optional context `el`.

### Selectable#select(els)

Add the given `els` to the selection.

### Selectable#deselect(els)

Remove the given `els` from the selection.

## License

MIT