我只是想让导航按钮保持彩色“ onclick”。我不明白为什么它不起作用...任何人都可以帮忙吗?
const about = document.getElementById('about-btn');
about.addEventListener ('click' () => {
about.style.backgroundColor = "#AAE0CE";
});
答案 0 :(得分:-2)
您有空格,无论如何应该会给您错误:
const about = document.getElementById('about-btn');
about.addEventListener('click', () => {
about.style.backgroundColor = "#AAE0CE";
});