let's start Code

HTML CODE FOR COPY TEXT

CODEBOX
        

<div class="main">
<div class="container">
<div class="codebox">
<div class="ipsCode_citation">
<div style="float: right;">
<button onclick="copyText()">//copy</button>
        </div>
//DELETE THIS LINE AND PASTE HERE WHICH CODE YOU WANT TO COPY ONE CLICK
</div>
</div>
</div>
</div>
<br />
<div id="output">
</div>
<script>
  function copyText(){
    var outputText = "";
    var targets = document.getElementsByClassName('codebox');
    for (var i = 0; i < targets.length; i++) {
      outputText += targets[i].innerText;
    }
    var output = document.getElementById('output');
    output.innerText = outputText;
    var range = document.createRange();
    range.selectNodeContents(output);
    var selection = window.getSelection();
    selection.removeAllRanges();
    selection.addRange(range);
    document.execCommand('copy');
    output.style.display = 'none';
  }
</script>

Share:

No comments:

Post a Comment

About

let's start CODE

Popular Posts