Invoke a callback when a user selects some text.
JavaScript HTML Makefile
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
History.md
Makefile
Readme.md
component.json
example.html
index.js

Readme.md

on-select

Invoke a callback when the user selects text in the page using the mouse or the keyboard.

Installation

Install with component(1):

$ component install yields/on-select

Example

var onselect = require('on-select');
var unbind = onselect(el, selected);

function selected(e){
  console.log(e);
  unbind();
}

API

onselect(el, fn)

Invoke fn(e, str) when a user selects within el.

str is the user selected text.

License

MIT