How to set Textarea Scroll Bar to Bottom as a Default using JavaScript/jQuery? Last Updated : 12 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report Given an HTML document containing <textarea> element and the task is to set the position of scrollbar to bottom of <textarea> with the help of jQuery. Below are the approaches to set the textarea scrollbar to the bottom:Table of ContentUsing jQueryUsing JavaScriptApproach 1: Using jQueryGet the scrollHeight property of the textarea.Use scrollTop property to set the position of the vertical scrollbar using jQuery. Example: This example implements the above approach. html <!DOCTYPE HTML> <html> <head> <title> JavaScript | Set textarea scroll bar to bottom as a default. </title> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"> </script> <style> #t { height: 100px; width: 300px; background: green; color: white; text-align:justify; } </style> </head> <body style = "text-align:center;"> <h1 style = "color:green;" > GeeksForGeeks </h1> <p id = "GFG_UP" style = "font-size: 15px; font-weight: bold;"> </p> <textarea id = "t"> GeeksforGeeks is a Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes etc. It also contains the practice section which is helpful for practicing the data structure and algorithms questions. GeeksforGeeks provides placement course, DSA class, Machine learning class and other online and offline courses which will help in placement and also growing the knowledge. </textarea> <br> <button onclick = "gfg_Run()"> click here </button> <p id = "GFG_DOWN" style = "color:green; font-size: 20px; font-weight: bold;"> </p> <script> let el_up = document.getElementById("GFG_UP"); let el_down = document.getElementById("GFG_DOWN"); el_up.innerHTML = "Click on the button to set " + "the scroll bar to bottom"; function gfg_Run() { $(document).ready(function(){ let $text = $('#t'); $text.scrollTop($text[0].scrollHeight); }); el_down.innerHTML = "Scroll bar is moved to bottom."; } </script> </body> </html> Output: Approach 2: Using JavaScriptThis example is doing the same job by JavaScript.Get the scrollHeight property of the textarea.Use scrollTop property to set the position of vertical scrollbar. Example: This example implements the above approach. html <!DOCTYPE HTML> <html> <head> <title> JavaScript | Set textarea scroll bar to bottom as a default. </title> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"> </script> <style> #t { height: 100px; width: 300px; background: green; color: white; text-align:justify; } </style> </head> <body style = "text-align:center;"> <h1 style = "color:green;" > GeeksForGeeks </h1> <p id = "GFG_UP" style = "font-size: 15px; font-weight: bold;"> </p> <textarea id = "t"> GeeksforGeeks is a Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes etc. It also contains the practice section which is helpful for practicing the data structure and algorithms questions. GeeksforGeeks provides placement course, DSA class, Machine learning class and other online and offline courses which will help in placement and also growing the knowledge. </textarea> <br> <button onclick = "gfg_Run()"> click here </button> <p id = "GFG_DOWN" style = "color:green; font-size: 20px; font-weight: bold;"> </p> <script> let el_up = document.getElementById("GFG_UP"); let el_down = document.getElementById("GFG_DOWN"); el_up.innerHTML = "Click on the button to set" + "the scroll bar to bottom"; function gfg_Run() { let text = document.getElementById('t'); text.scrollTop = text.scrollHeight; el_down.innerHTML = "Scroll bar is moved to bottom."; } </script> </body> </html> Output: Comment More infoAdvertise with us Next Article How to create auto-resize textarea using JavaScript/jQuery ? P PranchalKatiyar Follow Improve Article Tags : JavaScript JavaScript-Questions jQuery-Questions Similar Reads 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 arrow key in textarea using JavaScript ? Given an HTML element containing the <textarea> element and the task is to disable scrolling through arrow keys with the help of JavaScript. Approach 1: Add an event listener onkeydown on the window.If the event happens then check if the keys are arrow or not.If arrow key is pressed then preve 3 min read How to scroll down to bottom of page in selenium using JavaScriptExecutor Selenium is an open-source popular web-based automation tool. The major advantage of using selenium is, it supports all browsers like Google Chrome, Microsoft Edge, Mozilla Firefox, and Safari, works on all major OS and its scripts are written in various languages i.e Java, Python, JavaScript, C#, e 3 min read Scroll to the top of the page using JavaScript/jQuery Given a webpage and the task is to scroll to the top of the page using jQuery.A scrollable page can be scrolled to the top using 2 approaches: Table of ContentUsing window.scrollTo()Using scrollTop() in jQueryMethod 1: Using window.scrollTo()The scrollTo() method of the window Interface can be used 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 Disable Scrolling Temporarily using JavaScript? Disabling scrolling temporarily using JavaScript means preventing users from scrolling a webpage during specific interactions, such as when a modal is open or a loading screen is displayed. Scrolling can be disabled using JavaScript using 2 methods:Table of ContentUsing window.onscroll functionSetti 2 min read Like