<a href="javascript:;" onclick="copyText()">复制</a> <span id="text">222</span><input id="input"/>
function copyText() { var text = document.getElementById("text").innerText; var input = document.getElementById("input"); input.value = text; input.select(); document.execCommand("copy"); alert("复制成功"); }