To get the textbox value, you can use the jQuery val() function.

For example,

  1. $(‘input:textbox’).val() – Get textbox value.
  2. $(‘input:textbox’).val(“new text message”) – Set the textbox value.

Textbox example


<html>
<head>
<title>jQuery get textbox value example</title>
 
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>

</head>

<body>

<h1>jQuery get textbox value example</h1>

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
     style="display:block; text-align:center;"
     data-ad-format="fluid"
     data-ad-layout="in-article"
     data-ad-client="ca-pub-2836379775501347"
     data-ad-slot="6894224149"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script><h2>TextBox value : <label id="msg"></label></h2>

<div style="padding:16px;">
	TextBox : <input type="textbox" value="Type something"></input>
</div>
	
<button id="Get">Get TextBox Value</button> 
<button id="Set">Set To "ABC"</button> 
<button id="Reset">Reset It</button>

<script type="text/javascript">
    $("button:#Get").click(function () {
		
	$('#msg').html($('input:textbox').val());
		
    });
	
    $("button:#Reset").click(function () {
		
	$('#msg').html("");
	$('input:textbox').val("");
		
    });
	
    $("button:#Set").click(function () {
		
	$('input:textbox').val("ABC");
	$('#msg').html($('input:textbox').val());
		
    });
	
</script>

</body>
</html>