I want to copy a text to clipboard but in a new line.
Problem:
If you click the button in the snippet and paste in the notepad this is what
Your code is probably working well, but Notepad can't handle Unix' \n newlines, it only can handle \r\n and this is why you don't see them.
Please download a more advanced editor (like Notepad++, https://notepad-plus-plus.org) and try pasting it there. And not only that, but it has a lot of other very cool features like syntax highlighting, macros and plugins so it's worth using it for more purposes than that.
If you want to make the newlines work in MS apps, you need to replace the newlines just before you copy by using this line:
$temp = $temp.replace(/\n/g, "\r\n");
For printing in HTML you would need to replace \n with
, like this:
$temp = $temp.replace(/\n/g, "
");