set-input-value
Set an input's value without losing the user's cursor position.
Example
var set = ;var input = document; // Uppercase the value; // Add a prefix and shift the cursor accordinglyvar prefix = "A: ";;
API
set(input, value, shift)
Update the value of the given input element.
- input: input element to update
- value: new value
- shift: amount to shift the previous cursor by (default:
0
)
Browser Support
This module currently uses the
input.setSelectionRange
which is not supported in IE before version 9. A polyfill is possible -
see http://jsfiddle.net/EXH2k/6/.
Installation
npm install set-input-value