Cancel selected text in javascript, now compatible with all major browsers:
if (document.selection) {
document.selection.empty();
} else if (window.getSelection) {
window.getSelection().removeAllRanges();
}
For unselecting the text in the text box (input, textarea), this method will have some problems.
But there is also a way, record the value in the text box, and then Clear it and reassign it. The method is a bit confusing, but it is compatible with all browsers.
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn