简体   繁体   English

当我们使用javascript复制到剪贴板时,如何删除突出显示的文本选择

[英]How to remove text selection that is highlighted when we copy to clipboard using javascript

I am using the below code to copy and paste the text to clipboard using javascript. 我正在使用以下代码使用javascript复制文本并将其粘贴到剪贴板。 It basically selects the HTML element and shows a highlighter on that particular element . 它基本上选择HTML元素,并在该特定元素上显示突出显示。 Is it possible to remove the highlighter or any other way to handle this scenario? 是否可以删除荧光笔或其他任何方式来处理这种情况?

 copyInputMessage(inputElement){
    inputElement.select();
    document.execCommand('copy');
    inputElement.setSelectionRange(0, 0);
  }

try this 尝试这个

copyInputMessage(inputElement){
    inputElement.select();
    document.execCommand('copy');
    inputElement.setSelectionRange(0, 0);
    inputElement.blur(); 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM