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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -