js 取消选中的文字

用的是ConfirmBox   

当显示隐藏的时候 如果手动选中了内容 状态保留了 

var box = new ConfirmBox({
trigger: '',
title: '',
message: '',
confirmTpl: '',
cancelTpl: ''
}).after("show",function(){
document.selection && document.selection.empty && ( document.selection.empty(), 1)
|| window.getSelection && window.getSelection().removeAllRanges();
});

关键代码

document.selection && document.selection.empty && ( document.selection.empty(), 1)
            
|| window.getSelection && window.getSelection().removeAllRanges();

原文地址:https://www.cnblogs.com/lhy2013/p/3711908.html