javascript - how to insert text(<textarea> to <p>) with js -


how can inject text textarea p element, using javascript?

i have got far code see below.

  <button id="btn" onclick="show()">click</button>   <textarea placeholder="text..." id="textarea"></textarea>   <p id="sp"></p>   <script>     function show() {          var textarea = document.getelementbyid("textarea");         var p = document.getelementbyid("sp");         var text = document.createtextnode(textarea.innerhtml);         p.appendchild(text);//insert textarea     }   </script> 

var text = document.createtextnode(textarea.innerhtml); 

the innerhtml of element represents child nodes inside it. textarea set default value.

to current value need read value property instead.


Comments

Popular posts from this blog

iis - ASP.Net Core CreatedAtAction in HttpPost action returns 201 but entire request ends with 500 -

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -