I have this code:
You've got plenty of code here. It's always better to provide a minimal solution. I tried to build a minimal solution for you.
I's CSS only, the Javascript is only for clarification on how it works.
var buttons = document.querySelectorAll(".btn");
document.getElementById("toggle-disabled").addEventListener("click", function(e){
for(let i = 0; i < buttons.length; i++){
buttons[i].toggleAttribute("disabled");
}
});
.btn-disabled-warning {
display: none;
}
.btn[disabled] + .btn-disabled-warning {
color: red;
display: block;
}
The button is disabled :-(
The button is disabled :-(
讨论(0)