Answer the question
In order to leave comments, you need to log in
CSS. How to access an element by id?
How to access an element by ID.
I have two elements - span and input[checkbox].
I need the span styles to change when the checkbox changes.
The problem is that they are in different places on the page.
<div> <span id="sp">TEST</span> </div>
<div> <input type="checkbox" id="ch"> </div>
#ch: checked {
color: red;
}
Answer the question
In order to leave comments, you need to log in
With this markup on CSS, no way.
Variant without JS:
<input type="checkbox" id="ch">
<div>
<span id="sp" class="sp">TEST</span>
<label for="ch">тут стилизованный чекбокс</label>
</div>
#ch:checked + div .sp {}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question