Javascript examples for jQuery Method and Property:val
Return the value of the first 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(){ console.log($("input:text").val()); });/* w ww . j av a 2 s . com*/ }); </script> </head> <body> Firstname: <input type="text" name="fname" value="Peter"><br> Lastname: <input type="text" name="lname" value="Griffin"><br><br> <button>test</button> </body> </html>