In follow-up to an earlier question. I have the following script:
document.querySelector('.clickme').addEventListener('click', function() {
this.style.color = '#f00';
this.style.backgroundColor = '#fff';
});
...which means when the div .clickme
is clicked/tapped, the script changes .clickme
's own color
and backgroundColor
properties. Now, instead, I need the script to change not .clickme's
own properties, but the color
and backgroundColor
of another element on the page, a div class (let's call it) .zebra
. How should the script be modified to achieve that? (The target of the click/tap would still be .clickme
.)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…