我是 js 新手,在使用 nextElementSibling 属性更改按钮的 textContent 颜色时遇到问题
认为 e.target.childNodes.nextElementSibling.textContent.style.color = 'white' 会工作但没有(
您将
style
属性与 DOM 元素一起使用,而不是与 textContent
属性一起使用!从您的代码中删除textContent
以使其工作:
e.target.childNodes.nextElementSibling.style.color = "white";