How to Get the Value of an Input Text Box using jQuery? Last Updated : 08 Oct, 2024 Comments Improve Suggest changes Like Article Like Report When working with forms or interactive web pages, sometimes need to get the values entered into the input fields. This article provide a complete guide on how to get the value o an input text box using jQuery. Below are the different approaches to get the value of an input text box using jQuery:Get the Value of an Input Text Box using val() MethodjQuery val() method is used to get the value of an input text box. This function is used to set or return the value. To get the value of an input text box, you can simply call this method on the element.Syntax$('selector').val()Example: This example explains the steps to get the value of an input text box using jQuery. html <!DOCTYPE html> <html lang="en"> <head> <script src= "https://code.jquery.com/jquery-3.4.1.min.js"> </script> <script> $(document).ready(function () { // On button click, get value // of input control $("#getValBtnID").click(function () { const inputString = $("#userInputID").val(); alert(inputString); }); }); </script> </head> <body style="text-align: center"> <h3 style="color:green"> GeeksForGeeks </h3> <b>JQuery val() Method</b> <br><br> <input type="text" id="userInputID"> <br><br> <button type="button" id="getValBtnID"> Get Value </button> </body> </html> Output:Get the Value of an Input Text Box using prop() MethodThe prop() method can also be used to get the entered value of text box. Pass the property name as a parameter of prop() method and get the value of the passed property. In case of input text box, we will pass the value property as parameter to the prop() method.Syntax$('selector').prop('value');Example: The below example will explain the use of the prop() method to get the value of the input text box. HTML <!DOCTYPE html> <html lang="en"> <head> <script src= "https://code.jquery.com/jquery-3.4.1.min.js"> </script> <script> $(document).ready(function () { // On button click, get value // of input control $("#getValBtnID").click(function () { const inputString = $("#userInputID").prop('value'); alert(inputString); }); }); </script> </head> <body style="text-align: center;"> <h3 style="color:green"> GeeksForGeeks </h3> <b>JQuery val() Method</b> <br><br> <input type="text" value="" id="userInputID"> <br><br> <button type="button" id="getValBtnID"> Get Value </button> </body> </html> Output:jQuery is an open-source JavaScript library that simplifies the interactions between an HTML/CSS document, It is widely famous for its philosophy of “Write less, do more". You can learn jQuery from the ground up by following this jQuery Tutorial and jQuery Examples. Comment More infoAdvertise with us Next Article How to Get the Value of an Input Text Box using jQuery? M mohitgouti Follow Improve Article Tags : Web Technologies JQuery jQuery-Questions Similar Reads 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 How to create a Textarea Input Box using jQuery Mobile ? jQuery Mobile is a web based technology used to make responsive content that can be accessed on all smartphones, tablets and desktops. In this article, we will be a Textarea Input box using jQuery Mobile. Approach: Add jQuery Mobile scripts needed for your project. <link rel=âstylesheetâ href=âht 1 min read How to make a Value/Text Input using jQuery Mobile ? jQuery Mobile is a web based technology used to make responsive content that can be accessed on all smartphones, tablets and desktops. In this article, we will be creating a Value/Text Input using jQuery Mobile. Approach: Add jQuery Mobile scripts needed for your project. <link rel=âstylesheetâ h 1 min read How to get value of textbox in jQuery ? The purpose of this article is to demonstrate how we can get the value of textbox using jQuery. A basic understanding of HTML, CSS, and jQuery is required. This can be done by using the jQuery val() method. val() Method: This method is used to set or return the value of the attribute for the selecte 2 min read How to create a Text Input using jQuery Mobile ? jQuery Mobile is a web based technology used to make responsive content that can be accessed on all smartphones, tablets and desktops. In this article, we will be a Text Input using jQuery Mobile. Approach: First, we add the jQuery Mobile scripts needed for the project. <link rel=âstylesheetâ hre 1 min read How to change the checkbox value using jQuery ? The Checkboxes are used to let a user select one or more options for a limited number of choices. The :checkbox selector selects input elements with type checkbox.Syntax: $('#textboxID').val($("#checkboxID").is(':checked')); In the above syntax, basically the return value of the checked or unchecked 2 min read JQuery Set the Value of an Input Text Field Set the value of an input text field in jQuery is useful while working with forms. It is used to add new value to the input text field. In jQuery, there are various methods to set the value of input text fields, these are - val(), prop(), and attr(). These method offers unique capabilities for setti 3 min read How to get text value of a selected option in jQuery ? Introduction: In this article, we will see how we can use jQuery to get the text value from the selected option. While working on some form-related user interface, we often use the select option, and to use that, we will surely need those values that are being selected. Approach: We will use select 2 min read How to specify the value of an input element using HTML ? In this article, we will set the value of an input element using HTML. The value attribute for <input> element in HTML is used to specify the initial value of the input element. It has different meaning for different input type: The âbuttonâ, âresetâ and âsubmitâ property specifies the text on 1 min read Get the Value of Text Input Field using JavaScript Getting the value of a text input field using JavaScript refers to accessing the current content entered by a user in an input element, such as <input> or <textarea>, by utilizing the value property. This allows for dynamic interaction and data manipulation in web forms.Syntax inputField 2 min read Like