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 How to Change Text Inside all HTML Tags using JavaScript ? In this article, we will learn how to change the text content inside all HTML tags using JavaScript. This skill is valuable when you need to dynamically modify the text displayed on a web page. which can be useful for various scenarios like updating content, internationalization, or creating dynamic 3 min read How to create auto-resize textarea using JavaScript/jQuery ? Creating an auto-resize textarea using JavaScript or jQuery means dynamically adjusting the height of the textarea to fit its content as the user types. This enhances user experience by preventing the need for scrolling within the textarea, ensuring all content is visible.Table of ContentUsing JavaS 3 min read How to Disable Textarea using JavaScript? This article will show you how to disable the textarea using JavaScript. Disabling a textarea using JavaScript can be done by setting the disabled property of the textarea element to true. This prevents the user from editing the content of the textarea. There are some reasons to use disabled textare 2 min read How to create a textarea component in MATLAB Matlab offers tools for developing GUI applications. It provides functions that can create TextFields, Labels, Buttons, and many more, along with properties to manipulate the components. In this article, we will learn to create a TextArea Component using Matlab. Creating a textarea componentA Text A 4 min read How to detect âshift+enterâ and generate a new line in Textarea? The text area tag defines a multi-line text input control. The size of a text area can be specified by the cols and rows attributes. By default, whenever we press "enter" or "shift+enter" it creates a new line in the text area. So, to only detect "shift+enter" and generate a new line from it we need 2 min read Like