how to toggle hover display text of button on click

Solutions on MaxInterview for how to toggle hover display text of button on click by the best coders in the world

showing results for - "how to toggle hover display text of button on click"
Greta
31 Jan 2018
1// Use title attribute to show text on hover
2<button type="button" id="eye" title="Show Password" class="btn btn-light" onclick="show()"> <i class="fa fa-eye"></i> </button>
3
4<script>
5    function show() {
6        var y = document.getElementById("eye");
7        if (x.title === "Show Password") {
8            y.title = "Hide Password";
9        } else {
10            y.title = "Show Password";
11        }
12    }
13</script>