JS点击复制文字
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS点击复制文字Demo</title>
<script>
function copyText(message) {
var input = document.createElement("input");
input.value = message;
document.body.appendChild(input);
input.select();
input.setSelectionRange(0, input.value.length), document.execCommand('Copy');
document.body.removeChild(input);
alert("复制成功", "text");
}
</script>
</head>
<body>
<div onclick="copyText('要复制的内容')">点我</div>
</body>
</html>