How to get value from input field in jquery

How to Get the Value from Input Text Box using jQuery

In this tutorial, you will be learning that how to get value from input field using jQuery.

So, We can simply use the jQuery val() method to get the value from the given input text box.

Lets, follow the below given example and then click the "Show Data" button, it will display the result in an alert dialog box and console log.




<!DOCTYPE html>
<html lang="en">
    <title>jQuery Tutorials</title>

        <label>Enter the Value</label><br/>
        <input type="text" id="myInputValue" />

        <button type="button" id="myShowBtn">Show Data</button>

    <script src=""></script>
        $(document).ready(function () {
            $('#myShowBtn').click(function (e) {
                var str = $('#myInputValue').val();




Thanks for reading.

© Copyright - 2018 - 2023 | All rights reserved at Funda of Web IT