what is Wrong WIth this Code?? i have tried to color the span with red when the button is checked but that does't work with me
Asked
Active
Viewed 52 times
-2
-
Welcome to Stack Overflow! Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a [mcve]. Use the [edit] link to improve your *question* - do not add more information via comments. Thanks! – GhostCat May 21 '18 at 12:53
1 Answers
0
Try This:
For first span
:
input:checked ~ span:first-of-type {
color: red;
}
input:checked ~ span:first-of-type {
color: red;
}
<input type="checkbox" name="">Click
<br><span>mohammedSerwan</span>
<br><span>Mohammed2</span>
For all span
so use ~
:
input:checked ~ span {
color: red;
}
input:checked ~ span {
color: red;
}
<input type="checkbox" name="">Click
<br><span>mohammedSerwan</span>
<br><span>Mohammed2</span>

Ehsan
- 12,655
- 3
- 25
- 44