JSFiddle - React, Tailwind, and code Playground

by danielkwood

HTML

<html>
  <head>
    <title>querySelector() method</title>
    <script src="script.js"></script>
  </head>
  <body onload="load();">
    <p>Please enter your name</p>
    <input type="text" id="myTextInput"/>
    <button id="myButton">Submit</button>
    <p id="message"></p>
  </body>
</html>

JavaScript

function load(){
	document.querySelector("#myButton").addEventListener("click", getTextInput);
  }

function getTextInput(){
  var myTextInput = document.querySelector("#myTextInput").value;
  document.querySelector("#message").innerHTML = "Hello, " + myTextInput;
}