JavaScript Example | Get the Value of a Text Input

This javascript example will introduce how to get the value of a text input in html.

<!DOCTYPE html>
    <title>Title of the Document</title>
    <input type="text" placeholder="Type " id="inputId">
    <button type="button" onclick="getInputValue();">Get Value</button>
      function getInputValue() {
        // Selecting the input element and get its value 
        let inputVal = document.getElementById("inputId").value;
        // Displaying the value

The key point is: document.getElementById().