Javascript examples for jQuery Method and Property:val
Set the value of the input field
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("input:text").val(function(n, c){ return c + " test"; });/*from w w w . j av a2 s . c o m*/ }); }); </script> </head> <body> <p>Name: <input type="text" name="user" value="test"></p> <button>test</button> </body> </html>