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

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -