1 | initial version |
Here is an example of the process for automatically synchronizing the resizing of two textareas using JS and CSS:
<textarea id="textarea1"></textarea>
<textarea id="textarea2"></textarea>
textarea {
height: 200px;
}
const textarea1 = document.getElementById('textarea1');
const textarea2 = document.getElementById('textarea2');
textarea1.addEventListener('input', syncTextAreaHeight);
textarea2.addEventListener('input', syncTextAreaHeight);
function syncTextAreaHeight() {
const height = Math.max(textarea1.scrollHeight, textarea2.scrollHeight);
textarea1.style.height = height + 'px';
textarea2.style.height = height + 'px';
}
Test the textareas by typing text in one textarea and checking that the other resizes to match the height of the first.
You may need to adjust the CSS if the textareas do not resize properly.
Note: This is just one example of how to automatically synchronize the resizing of two textareas. There are many other ways to achieve the same effect.