0.2.2 • Published 9 years ago

field-selection v0.2.2

Weekly downloads
140
License
-
Repository
github
Last release
9 years ago

Get text selection or replace selected text in input field or textarea.

Get selection.

// As jquery plugin
$(selector).fieldSelection(); // {start: xxx, end: xxx, length: xxx, text: xxx}

// As commonjs module
var fieldSelection = require('field-selection');
fieldSelection.get(element);

// Via window global.
window.fieldSelection.get(element);

Replace selection - insert a string at caret position.

// As jquery plugin
$(selector).fieldSelection('My text');

// As commonjs module
var fieldSelection = require('field-selection');
fieldSelection.replace(element, 'new text');

// Via window global.
window.fieldSelection.replace(element, 'new text');