JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" id="input1" />
<input type="button" id="button1" value="Click Me" />
JavaScript
$(function() {
$("#button1").click(function() {
$("#input1").replaceWith($("<input>").attr({ "type": "password", "id": "input1" }));
});
});