Add New line to a div contenteditable in javascript - Javascript DOM

Javascript examples for DOM:Element innerHTML

Description

Add New line to a div contenteditable in 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://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script> 
      <script type="text/javascript">
    window.onload=function(){// w  ww. ja  v  a 2 s  .  c o  m
var hello = "hello<br>how\nare\nyou";
document.getElementById("hey").innerHTML = hello;
    }

      </script> 
   </head> 
   <body> 
      <div id="hey"></div>  
   </body>
</html>

Related Tutorials