I'm having a problem changing the status indicator of elements in an html form. Pseudo-code as below:
<div class="master">
/*Section 1*/
<div>
<input type="checkbox" /> /*Display .content div*/
<label> Label of this section <span class="done"></span></label>
<div class="content">
<p>Content that is initially hidden</p>
<div class"check>
<input type="checkbox" /> /*Change .done span*/
</div>
</div>
</div>
/*Section 2*/
<div>
/*As above, 30 different sections*/
</div>
</div>
The .content div is initially hidden. When the user clicks the first checkbox, this .content div is shown.
I have been using the css snippet below to handle displaying the .content div (using general sibling selectors):
.content{ eg. opacity: 0;}
.master input:checked ~ .content{ eg. opacity: 1;}
This is working fine, however I haven't been able to figure out anything similar for the second checkbox to target the .done span.
The .done span within label is initially a red cross. When the user clicks the second checkbox I would like to be able to target this span so I can restyle it into a green tick.
As there are many sections I only want to target the particular .done span that the checkbox relates to.
Is this possible with the way I have my html set up?
If so, how would I go about implementing what I would like to do?
If not, what would your recommendations be?
Should I just use a bunch of unique id's for the spans instead of a class?
Thanks!
EDIT
I ended up using jQuery for this since the css was going to get so messy.
If anyone is curious, here is what ended up working:
$(".check").click(function(){
//Basically just goes up the hierarchy to find the label then toggles the class as appropriate
$(this).parent().parent().parent().children("label").children("span").toggleClass('done').toggleClass('notDone');
});