求一段html代码:点击「复制」按钮,提示「复制成功」!

出處:https://zhidao.baidu.com/question/77403775.html

<!doctype html>
<html>
 <head>
  <title>复制文本框</title>
 </head>
 <body>
<textarea id='text'></textarea>
<button id='copy' onclick=copy()>复制</button>
 </body>
</html>
<script>
function copy(){
var text=document.getElementById('text');
var copy=document.getElementById('copy');
text.select();
document.execCommand("copy");
copy.focus();
alert("复制完成!")
}
</script>