<!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>
网友评论