how to copy from js the lines of an html

Solutions on MaxInterview for how to copy from js the lines of an html by the best coders in the world

showing results for - "how to copy from js the lines of an html"
Gemma
03 Sep 2019
1function copyToClipboard(element) {
2  var $temp = $("<textarea>");
3  var brRegex = /<br\s*[\/]?>/gi;
4  $("body").append($temp);
5  $temp.val($(element).html().replace(brRegex, "\r\n")).select();
6  document.execCommand("copy");
7  $temp.remove();
8}
9
10$( "#FailCopy" ).click(function() {
11  alert("Well done! div #error-details has been copy to your clipboard, now paste it in the notepad or email!");
12});