Tryit Editor v1.8

Source Code:
<!DOCTYPE html> <html> <head> <script src="../../ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("button").click(function(){ $("input:text").val(function(n,c){ return c + " Griffin"; }); }); }); </script> </head> <body> <p>Name: <input type="text" name="user" value="Peter"></p> <button>Set the value of the input field</button> </body> </html>
Result:
W3Schools.com - Try it yourself