In this example we will discuss How to GET & SET value in jQuery.
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#get").click(function(){
var first_name=$("#first_name").val();
var last_name=$("#last_name").val();
alert(first_name + " " +last_name);
});
$("#set").click(function(){
$("#first_name").val("Larry");
$("#last_name").val("Hen");
});
});
</script>
</head>
<body>
<input type="text" name="first_name" value="John" id="first_name">
<input type="text" name="first_name" value="Deo" id="last_name"><br><br>
<button id="get">GET Value</button>
<button id="set">SET Value</button>
</body>
</html>
Run it Yourself »