jQuery Form How to - Set value for textarea with new line sign








Question

We would like to know how to set value for textarea with new line sign.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type='text/javascript'>
$(window).load(function(){<!--from ww  w.  j a va2 s  .  c o  m-->
    $("textarea").val("abc\n\u202Edef\nghi")
});
</script>
</head>
<body>
  <textarea style="width: 80px; height: 120px"></textarea>
</body>
</html>

The code above is rendered as follows: