I have a Tampermonkey script that creates a list of values from checked checkboxes on a webpage. The box displays the data beautifully, each value on a new line below the other. However, I lose the newline characters when I copy and paste these values using Microsoft clipboard. Is there a way to adjust the script in order to allow preservation of the newline characters (\n
)?
JavaScript:
var box = document.createElement( 'div' );
box.id = 'myAlertBox';
document.body.appendChild( box );
box.textContent = text + '\n';
var selectedQueries = document.querySelectorAll (query);
selectedQueries.forEach ( (chkBox) => {
box.textContent += chkBox.title + '\n';
});
CSS:
#myAlertBox {
font-size: small;
background: white;
border: 5px solid green;
padding: 4px;
position: absolute;
top: 280px; right: 80px;
max-width: 300px;
white-space:pre-wrap;
}
tags?](https://stackoverflow.com/questions/784539/how-do-i-replace-all-line-breaks-in-a-string-with-br-tags) – Terry Sep 21 '17 at 15:09
`. This can be done using regular expression. – Terry Sep 21 '17 at 15:09