javascript button toggle on off

Solutions on MaxInterview for javascript button toggle on off by the best coders in the world

showing results for - "javascript button toggle on off"
Elías
03 Aug 2019
1<div class="form-check form-switch"> <input class="form-check-input" type="checkbox" id="flexSwitchCheckDefault"></div>
2<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js"></script>
3<script>
4const btn = document.querySelector(".form-check-input")
5label = document.querySelector(".form-check-label");
6btn.addEventListener("change", function() {
7    this.checked ? label.innerHTML = "Button Turned On" :
8        label.innerHTML = "Button Turned Off"
9});
10</script>
similar questions
toggle button