Javascript examples for jQuery Method and Property:val
Get the value of an input field with the val() method
<!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("Value: " + $("#test").val()); });/*from www. j a v a2 s. c o m*/ }); </script> </head> <body> <p>Name: <input type="text" id="test" value="Mickey Mouse"></p> <button>Show Value</button> </body> </html>