jQuery textarea value doesn't convert line breaks

You need to use the HTML character entity for line break within an HTML property: 

var html = 'this\ntest';
var div = $('#test').data('message');

$('#textarea').val(html);
$('#textarea2').val(div);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="test" data-message="this&#13;test"></div>
<textarea id="textarea"></textarea>
<textarea id="textarea2"></textarea>


When you get it from the data attribute the\n is becoming escaped so you need to replace it:

$('#textarea2').val(div.replace("\\n","\n"));

Example