JavaScript实现选中文字自动复制
<script>
//获取复制区域id
var oContent =document.getElementById('txtbox');
oContent.onmouseup = function(){
alert(selectText());
};
function selectText(){
if(document.Selection){
//ie浏览器
return document.selection.createRange().text;
}else{
//标准浏览器
return window.getSelection().toString();
}
}
var oContent =document.getElementById('txtbox');
oContent.onmouseup = function(){
document.execCommand("Copy");
};
</script>
欢迎访问每天进步网:https://meitianjinbu.cn/

浙公网安备 33010602011771号