Selectables
Select elements in webpage with mouse.
Simple js without external dependencies.
Demo
Usage:
dr = zone:'#div' elements: 'li' { console; }; //laterdr; // enable againdr; // set optionsdroptionskey='altKey';
Options and Callbacks:
// root element whith selectables. zone: "#wrapper" // items to be selectable .list-group, #id > .class,'htmlelement' - valid querySelectorAll elements: "li" // class name to apply to seleted items selectedClass: 'active' // event on selection start { console; } // event on selection end { console; } // event fired on every item when selected. { console console; } // event fired on every item when selected. { console; } // activate using optional key key: false //'altKey,ctrlKey,metaKey,false // add more to selection moreUsing: 'shiftKey' //altKey,ctrlKey,metaKey //false to .enable() at later time enabled: true
Example usage
Toggle multiple checkboxes in list
{ el;} { el;}
Install
npm install selectables
or
bower install selectables
Example extension
Custom method declared after selectables.js is loaded.
Selectablesprototype { var opt = thisoptions; this
Notes
-
Multiple instances on different zones and items are possible, but it is good to enable them only when needed.
-
When selecting, "noselect" class gets applied to the zone, to avoid unwanted text selections.
Why?
Created in effort to drop code size and dependency on jquery && jquery.ui for small projects.