How to Get the Value in an Input Text Box using jQuery

  1297 views   2 years ago jQuery

Use the jQuery val() Method

You can simply use the jQuery val() method to get the value in an input text box.

Try out the following example by entering something in the text input box and then click the "Show Value" button, it will display the result in an alert dialog box.

<!DOCTYPE html>
<html lang="en">
<title>jQuery Get the Value of an Input Text Box</title>
<script src=""></script>
    // Get value on button click and show alert
        var str = $("#myInput").val();
    <input type="text" id="myInput">
    <button type="button" id="myBtn">Show Value</button>


Author : Harsukh Makwana
Harsukh Makwana

Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]