I have some very basic Javascript that copies text upon the push of a button. My problem is that it doesnt preserve line breaks:
<script>
function copyToClipboard(element) {
var $temp = $("<input>");
$("body").append($temp);
$temp.val($(element).text()).select();
document.execCommand("copy");
$temp.remove();
}
</script>
I'd really like something to be able to be added to the above script to avoid making huge changes on the site already.
I've seen things on other posts such as:
post.innerHTML = post.innerHTML.replace(/
/g, '<br>
');
which in theory would work (i think) but I suck at Javascript.
Any suggestions?
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…