cara beralih melayang tampilan teks tombol pada klik

// Use title attribute to show text on hover
<button type="button" id="eye" title="Show Password" class="btn btn-light" onclick="show()"> <i class="fa fa-eye"></i> </button>

<script>
    function show() {
        var y = document.getElementById("eye");
        if (x.title === "Show Password") {
            y.title = "Hide Password";
        } else {
            y.title = "Show Password";
        }
    }
</script>
Lone Wolf