JSFiddle - React, Tailwind, and code Playground

by crduling

HTML

<div>
Hi there!
</div>

<button>
  Get textarea value
</button>

JavaScript

var textareaValue = $("div").text(); //"Hi there!" is what is retreived from database

$("div").replaceWith("<textarea>" + textareaValue + "</textarea>"); //changes div to textarea with original value, "Hi there!", included.

//now, I want to change the value of the textarea. So, for example, if I type "I like pizza" in the textarea, when I get the updated value, its value should change. The problem is it doesn't change.

$("button").click(function() {

	var newTextareaValue = $("textarea").val();
  alert(newTextareaValue);

});