JSFiddle - React, Tailwind, and code Playground

HTML

<input id="test">

JavaScript

$("#test").prop("required", true);