JSFiddle - React, Tailwind, and code Playground

by the94air

HTML

<form id="my-form">
  <input id="my-name" type="text">
  <button type="submit">Submit</button>
</form>

JavaScript

const myForm = document.getElementById("my-form");
const myName = document.getElementById("my-name");

myForm.addEventListener("submit", function formHandler(e) {
  const name = myName.value;
  console.log(name);
  e.preventDefault();
});