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

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

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -