英文:
Disable buttons but keep style
问题
Is there a way to disable buttons but keep the default style? Not have them greyed out? currently, the buttons are disabled correctly but are shown as greyed out. I have found a similar question however they were using jQuery and I need to use vanilla JavaScript.
function disableAnswers() {
for (let i = 0; i < answers.length; i++) {
answers[i].disabled = true;
}
nextQ.classList.remove('hidden');
}
英文:
Is there a way to disable buttons but keep the default style? Not have them greyed out? currently, the buttons are disabled correctly but are shown as greyed out. I have found a similar question however they were using jQuery and I need to use vanilla JavaScript.
function disableAnswers() {
for (let i = 0; i < answers.length; i++) {
answers[i].disabled = true;
}
nextQ.classList.remove('hidden');
}
答案1
得分: 2
你可以使用简单的CSS来处理这个:
button:disabled {
color: initial;
}
<button disabled>Button</button>
英文:
You can handle this with simple CSS:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
button:disabled {
color: initial;
}
<!-- language: lang-html -->
<button disabled>Button</button>
<!-- end snippet -->
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论