Converting Escaped Literals to Specials with JavaScript - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:val

Description

Converting Escaped Literals to Specials with JavaScript

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.5.2.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/* w w w  .j  av  a  2s .co m*/
var str = 'aaasddd this is a test asdf';
console.log(
    str.replace('s',$('#my').val().replace(/\\n/g,'\n'))
);
    });

      </script> 
 </head> 
 <body> 
  <input id="my" value="\n">  
 </body>
</html>

Related Tutorials