Working with textarea in JavaScript

In this section of the tutorial, you and I will learn how to work with more advanced forms features. Let's start with the textarea tag, which is a multi-line input field.

When working with this tag, there is some nuance. The bottom line is this: the text that will be in tag by default is located between the opening and closing textarea tags:

<textarea id="elem">text</textarea>


However, despite this, the tag text should be read and written not through the innerHTML property, but through value. For example, let's display the text of the above textarea:

let elem = document.querySelector('#elem'); console.log(elem.value); // shows 'text'

Given a textarea and a paragraph. When textarea loses focus, write its text into the paragraph.