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
Post a Comment