All Projects β†’ bevacqua β†’ seleccion

bevacqua / seleccion

Licence: MIT license
πŸ’΅ A getSelection polyfill and a setSelection ranch dressing

Programming Languages

javascript
184084 projects - #8 most used programming language

seleccion

A getSelection polyfill and a setSelection ranch dressing

Includes also a setSelection method. See also sell to work with selection within <input> and <textarea> elements.

install

npm install seleccion

seleccion.get()

Provides a polyfill for window.getSelection.

var getSelection = require('seleccion').get;
var range = getSelection();
  • Defaults to window.getSelection if available
  • Falls back to document.selection
  • Falls back to a naΓ―ve null object if both are unavailable

seleccion.set(range)

Provides a convenient cross-browser method to set the text selection using a range TextRange.

var setSelection = require('seleccion').set;
setSelection({
  startContainer: document.querySelector('#some-span'),
  startOffset: 0,
  endContainer: document.querySelector('#another-span'),
  endOffset: 24,
  collapsed: false
});

license

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].