文本复制
<!DOCTYPE html>
<html>
<body onclick="myFunction(event)">
<p>The executeCommand() method executes a specified command on selected text or section.</p>
<script>
document.designMode = "on";
let p=document.querySelector('p')
let y=document.querySelector('body')
function myFunction(event) {
let a=p.innerText
let b=document.createElement('input')
b.value=a
y.appendChild(b)
b.select()
document.execCommand("copy")
y.removeChild(b)
}
</script>
</body>
</html>
本文标题:文本复制
本文链接:https://www.haomeiwen.com/subject/zmwkyftx.html
网友评论