Here is my markup:
<p>This is <span class="rounded">some</span> text which <span class="rounded">shows</span> what I <span class="rounded">want</span> to do.</p>
I have the following CSS:
span.rounded:not(.clicked):nth-child(1) {
background: red;
}
So, this turns the background of first rounded element to red.
Now, if i click on the word some, it applies a class clicked to the wrapping span tag. The HTML now looks like this:
<p>This is <span class="rounded clicked">some</span> text which <span class="rounded">shows</span> what I <span class="rounded">want</span> to do.</p>
At this point, I expect to word shows to have a red background because it seems to satisfy the selector:
span.rounded:not(.clicked):nth-child(1) {
background: red;
}
However, no other tag ever becomes red. What am I doing wrong?
How can I make the next tag red after the current one has been clicked?
Thanks.