Toggle Selection

Simple module exposing function that deselects current browser selection and returns function that restores selection.

  1. var deselect = require('toggle-selection');
  2. var reselect = deselect(); // remove all selection
  3. // …
  4. // do something with current selection, text, etc;
  5. // …
  6. reselect(); // restore selection

All credits go to @shvaikalesh.

Example

example recording