JSFiddle - React, Tailwind, and code Playground

by rami7250

HTML

<textarea id="p1" name="select1" rows=3 cols=75 style="">
    <a href="google.com">Google</a>
</textarea>

  <!-- copy to clipboard-->
<button class="button-main" style="max-width:200px;" onclick="copyToClipboard('#p1')">Copy Text</button>
<script type="text/javascript">    
function copyToClipboard(element) {
  var $temp = $("<input>");
  $("body").append($temp);
  $temp.val($(element).text()).select();
  document.execCommand("copy");
  $temp.remove();
} 
    </script>

JavaScript

var copytoclip=1
function HighlightAll(theField) {
    var tempval=eval("document."+theField)
    tempval.focus()
    tempval.select()
    if (document.all&&copytoclip==1){
        therange=tempval.createTextRange()
        therange.execCommand("Copy")
        window.status="Contents highlighted and copied to clipboard!"
        setTimeout("window.status=''",1800)
    }
}