<style>
.pop_tip{
position: absolute;
top: 10%;
left: 50%;
transform:translateX(-50%);
background:#eee ;
padding:25px 50px;
font-size:16px;
display: none;
z-index: 1000;
}
</style>
<script language="javascript">
function copytext() { var Url2 = $("#tar_text").text(); var oInput = document.createElement('input'); oInput.value = Url2; document.body.appendChild(oInput); // oInput.select(); selectText(oInput) document.execCommand("Copy"); oInput.className = 'oInput'; oInput.style.display = 'none'; alert('复制成功!'); // var tip ="<div class='pop_tip' >复制成功!</div>" // $ ('.pop_tip').show ().delay (3000).fadeOut (); } function selectText(oInput) { if(oInput.createTextRange) {//ie oInput.select(); }else{//firefox/chrome oInput.setSelectionRange(0, oInput.value.length); oInput.focus(); } }</script>
<div><span id="tar_text" >111</span> <input type="button" id="btn_copy" style="background: #0db37f; color: white; width: 60px; height: 30px; text-align:center;" onclick="copytext()" value="复制"/> </div>