We can easily access the value of HTML input tag and we can also set the value of input tag using the jQuery val() function.
$("TagSelector").val(); //Syntax
$("#username").val(); //Example
For setting or assigning the value to HTML input tag.
$("TagSelector").val("Field Value");
Let's considering two examples , example to get the the value of input field and example to assign or set the value to the input field.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button id="mybutton"> Get input tag Value</button>
<input id="username" value="codinpk@codingpk.com" />
<script type="text/javascript">
$("#mybutton").click(function()
{
var username= $("#username").val();
alert(username);
});
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button id="mybutton1"> Set Input Tag value</button>
<input id="password" value="" />
<script type="text/javascript">
$("#mybutton1").click(function()
{
var password= $("#password").val('jQuery121');
});
</script>