JavaScript - How to Change the Content of a <Textarea> ? Last Updated : 17 Apr, 2025 Comments Improve Suggest changes Like Article Like Report Here are the various methods to change the content of a textarea using JavaScript.1. Using value PropertyThe value property is the most common method to change or retrieve the content of a <textarea>. HTML <textarea id="myTextarea">Initial content</textarea> <button onclick="changeContent()">Change Content</button> <script> function changeContent() { const textarea = document.getElementById("myTextarea"); textarea.value = "New content using value property!"; } </script> OutputChange the Content of a Textarea using JavaScript2. Using innerHTML PropertyWhile innerHTML is not typically used for <textarea>, it can modify its content when treated as a standard HTML element. HTML <textarea id="myTextarea">Initial content</textarea> <button onclick="changeContent()">Change Content</button> <script> function changeContent() { const textarea = document.getElementById("myTextarea"); textarea.innerHTML = "New content using innerHTML!"; } </script> OutputChange the Content of a Textarea using JavaScript3. Using innerText PropertySimilar to innerHTML, this property modify the visible text of the <textarea>. HTML <textarea id="myText">Initial content</textarea> <button onclick="changeText()">Change Content</button> <script> function changeText() { const textarea = document.getElementById("myText"); textarea.innerText = "New content using innerText!"; } </script> OutputChange the Content of a Textarea using JavaScript4. Using Event Listeners for Dynamic UpdatesYou can use event listeners to change the content interactively. HTML <textarea id="myText">Initial content</textarea> <button id="updateButton">Change Content</button> <script> document.getElementById("updateButton").addEventListener("click", () => { const textarea = document.getElementById("myText"); textarea.value = "Content updated using event listeners!"; }); </script> Output Change the Content of a Textarea using JavaScriptWhich approach to choose?value Property: Most common and versatile.innerHTML/innerText: Rarely used for <textarea>; more suited for other elements.Event Listeners: Best for dynamic and interactive updates. Comment More infoAdvertise with us Next Article JavaScript - How to Change the Content of a <Textarea> ? R Rajnis09 Follow Improve Article Tags : JavaScript Web Technologies javascript-string JavaScript-Questions Similar Reads How to change the shape of a textarea using JavaScript ? In General, Textarea will be in the form of rectangular or square shapes, but here we will deal with Unusual shapes of textarea which means this textarea will not be regular shapes but editable. Method 1: In the first method, let's see the irregular editable textarea created using CSS-shapes and con 2 min read JavaScript Change the Text of a Span Element Updating the text of HTML elements, such as a <span> in JavaScript allows developers to dynamically alter webpage content. This technique is used for creating interactive web features like displaying user feedback, updating real-time data, or modifying elements based on user actions. Here, we' 3 min read How to Add Text Formatting to a Textarea using JavaScript? To add text formatting (such as bold, italic, or inserting special characters) to a <textarea> using JavaScript, you can manipulate the selected text or insert formatted text at the cursor position. This can be done by directly modifying the value of the <textarea> based on user interact 3 min read How to get the value of a textarea in jQuery ? To get the value of a textarea in jQuery, you can use the val() method. This method is commonly used to retrieve the current value of form elements like textarea, input, and select. It works by either retrieving or setting the value of the selected element. If no input is provided, the method return 2 min read Create a Character Limit Textarea using HTML CSS and JavaScript In this article, we will create a Character Limit Textarea using HTML, CSS, and JavaScript.In this application, we will display the text area as an input component to the user and there is a predefined limit set to accept the input. When the limit is been crossed the user will get the alert message 6 min read Like