javascript - Convert innerHTML to text and put into textarea not working -


i want take inner html (both tags , text) of element , put in textarea, somehow not working. how can make work , why not working?

html:

<div id="element">     <p>some text</p>     <p>some text</p> </div> <button>click me</button> 

js:

$("button").click(function(){     $("#element").html("<textarea>"+$("#element").text($("#element").html())+"</textarea>"); }); 

demo

$("#element").text($("#element").html()) 

there's problem should be

$("#element").text() 

jsfiddle

edit:

updated fiddle


Comments

Popular posts from this blog

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -