JQuery TextBox Value()

JQuery TextBox Value()

You want to get value of input textbox using JQuery. Here is simple code that gives you value of textbox.

JQuery Get Value Example

<script type="text/javascript" language="javascript">
   

$(document).ready( function (){ 

    $("#Button1").click( function(){      
         
        var inputValue = $("#txtName").val();
        alert(inputValue);

     });
                    
 });

</script>

Description

$("#txtName").val();

Above val() function returns value of TextBox. $(“#txtName”) finds the element by ID “txtName”.

Complete HTML Code

<html>
<head>
    <title>Jquery Get TextBox Value</title>
  
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript"></script>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

<script type="text/javascript" language="javascript">
   

$(document).ready( function (){ 

    $("#Button1").click( function(){      
         
        var inputValue = $("#txtName").val();
        alert(inputValue);

     });
                    
 });

</script>

</head>
<body>
    <div>        
         <input id="txtName" type="text" />
           <input id="Button1" type="button" value="Click To Get Value" />                     
    </div>
</body>
</html>

Tags:

Jquery

JQuery Set Value of Textbox or Label Control In Asp.netJQuery TextBox Value()Jquery Set Value Of Textbox.JQuery Hidden Field Set ValueGet Selected Value From Dropdownlist [JQuery]How to get Jquery selected optionJQuery get Value Of TextareaJQuery access label control and set valueLearning JqueryBasics of jqueryJquery textbox KeyUp event

Author

My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in ASP.net year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.
 

I'm Satalaj.