I have an input (text field) in update panel, and it autopostbacks after each change of text. I can keep focus on the same text field, but i can’t get rid of text higlight which appears after calling document.getElementById(‘myTextField’).focus().
This solution seemed to be the most accurate:
if (window.getSelection) {
window.getSelection().removeAllRanges();
} else if (document.selection) {
document.selection.empty();
}
But it has one problem. Input remains focused, but i can’t write text. I have to click on it before writing.
You can do it if you reset your value after focus, i.e.
HTML
JS
Working Example.