Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to copy from js the lines of an html

function copyToClipboard(element) {
  var $temp = $("<textarea>");
  var brRegex = /<brs*[/]?>/gi;
  $("body").append($temp);
  $temp.val($(element).html().replace(brRegex, "
")).select();
  document.execCommand("copy");
  $temp.remove();
}

$( "#FailCopy" ).click(function() {
  alert("Well done! div #error-details has been copy to your clipboard, now paste it in the notepad or email!");
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #copy #js #lines #html
ADD COMMENT
Topic
Name
6+1 =