If I write my new line character 
 directly as HTML attribute, then it can work for CSS generated content. For example:
div::after {
content: attr(data-generated-content);
white-space: pre;
}
<div data-generated-content="First line
Second line"></div>
However, if the new line character was added via jQuery, then it doesn't work. For example:
$(document).ready(function() {
$('div').attr('data-generated-content', 'First line
Second line');
});
div::after {
content: attr(data-generated-content);
white-space: pre;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<div></div>
Here is a complete demo on jsFiddle.
How do I make the new line character added via jQuery work for CSS generated content?