Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the Document</title> </head> <body> <input type="text" placeholder="Type " id="inputId"> <button type="button" onclick="getInputValue();">Get Value</button> <script> function getInputValue() { // Selecting the input element and get its value let inputVal = document.getElementById("inputId").value; // Displaying the value alert(inputVal); } </script> </body> </html>