HTML + JS 方式
使用 HTML 和 JS 结合调用配合完成复制功能。
HTML 代码
<form role="form" action="" method="post">
<input type="text" id="htmlcode">
<input type="button" onClick="copyCodeButton()" value="复制">
</form>
JS 代码
<script type="text/javascript">
function copyCodeButton(){
var copyCommand=document.getElementById("htmlcode");
copyCommand.select();
document.execCommand("Copy");
}
</script>
纯 HTML 代码
<form role="form" action="" method="post">
<input type="text" id="htmlcode">
<input name="button" type="button" onclick="htmlcode.select();document.execCommand("Copy")" value="复制">
</form>
0 条评论