Storing text area input with \n value in string - Javascript jQuery

Javascript examples for jQuery:String

Description

Storing text area input with \n value in string

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.10.1.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/*www  .jav a2 s .  c om*/
$("textarea").keydown(function(){
    $('#txt').html($("textarea").val().replace(/\r?\n/g,"\\n"));
}).keyup(function(){$("textarea").keydown()});
    });

      </script> 
 </head> 
 <body> 
  <textarea></textarea> 
  <div id="txt"></div>  
 </body>
</html>

Related Tutorials