How to get data from textarea in JS
We can easily get the textarea’s data by setting its ID and referring to its value with document.getElementById()
.
Example:
<textarea id="myText">Hello</textarea><br><br>
<button type="" onclick="runAlert()">Run the alert!</button>
<script>
function runAlert() {
var myText = document.getElementById('myText').value;
alert(myText);
}
</script>
Output: