A JavaScript handles the characters in the textarea into each line instance

  • 2020-03-30 04:00:04
  • OfStack

  <!doctype html> 
  <html lang="en"> 
    <head> 
    <meta charset="utf-8"> 
    <title> Every day a JavaScript The instance - To deal with textarea In each line </title> 
    <script> 
       
        function clicka(){ 
          console.log("aaa"); 
          var aa = document.getElementById("text"); 
          var lines = aa.value.split("n"); 
          var bbb = document.getElementById("result"); 
          var string = ""; 
          for(i=0;i<lines.length;i++){ 
            string+= lines[i]+"<br />";////</ br> And <Br /> Should use <Br />
          } 
          bbb.innerHTML=string 
          } 
         
    </script> 
    </head> 
   
    <body>     
    <textarea id="text" placeholder=" Please enter multiple lines of text "></textarea> 
    <div id = "result"></div>         
    <a href="javascript:void(0);" onClick="clicka()"> Processing line </a>                       
    </body> 
    </html>

Related articles: