toggle-selection

Toggle current selected content in browser

Usage no npm install needed!

<script type="module">
  import toggleSelection from 'https://cdn.skypack.dev/toggle-selection';
</script>

README

Toggle Selection

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

var deselect = require('toggle-selection');
var reselect = deselect(); // remove all selection
// … 
// do something with current selection, text, etc;
// …
reselect(); // restore selection

All credits go to @shvaikalesh.

Example

example recording