JSFiddle - React, Tailwind, and code Playground

by techiedelight

HTML

<label>Email address: <input type="email" id="name" placeholder="Enter email"></label>

JavaScript

if (document.querySelectorAll("#name").length) {
  alert("The element exists");
} else {
  alert("The element does not exist");
}