JSFiddle - React, Tailwind, and code Playground

HTML

<body>
    <div id="loginBox">
        <form>
            <input type="text" id="username_input" name="username" /><br />
            <input type="text" id="password_input" name="password" />
        </form>
    </div>
</body>

JavaScript

$('<input type="password" id="password_input" name="password" />').insertAfter('#password_input').prev().remove();
alert($('form').html());