Exercise:
Alert the value of the input field.
Hint
Hint: Use the val() method.
Edit This Code:
See Result »
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script> <script> $(document).ready(function(){ // add code here }); </script> </head> <body> Name: <input type="text" value="Mickey Mouse"> </body> </html>
Result:
Show Answer
Correct Code:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script> <script> $(document).ready(function(){ alert($("input").val()); }); </script> </head> <body> Name: <input type="text" value="Mickey Mouse"> </body> </html>
Correct Result:
Hide Answer
Privacy Policy