Copy Container Text in JavaScript

Copy Container Text in JavaScript
<script type="text/javascript">

function myFunction() {

  /* Get the text field */

  var copyText = document.getElementById("myInput");

  /* Select the text field */

  copyText.select();


  /* Copy the text inside the text field */

  document.execCommand("Copy");


  /* Alert the copied text */

  alert("Copied the text: " + copyText.value);

}

</script>