JSFiddle - React, Tailwind, and code Playground

HTML

<input type="password" id="mytext" />
<input id="passChk" type="checkbox" />

JavaScript

$(function() {
    $("#passChk").change(function(){
        if(this.checked) {
            $("#mytext").attr("type","password");
        } else {
            $("#mytext").attr("type","text");
        }
    });
});