Benny_2306
Coder
I basically know no JavaScript at all yet i need it for my current project i am working on to learn scss and html. I have a set of radio buttons an what i need is if a radiobutton is checked, that its label and the labels bofre it get a extra class inserted. (e.g. if radiobutton 4 was checked, the labels of the buutons 1-4 should have the extra class)
This is the html code Iused to try figure it out myself but just couldn't get it to work.
This is an example of how it should look like if radiobutton 4 were selected.
HTML:
<div class="container">
<input name="test" type="radio" class="radio" id="1">
<input name="test" type="radio" class="radio" id="2">
<input name="test" type="radio" class="radio" id="3">
<input name="test" type="radio" class="radio" id="4">
<input name="test" type="radio" class="radio" id="5">
<label for="1" class="label">Label</label>
<label for="2" class="label">Label</label>
<label for="3" class="label">Label</label>
<label for="4" class="label">Label</label>
<label for="5" class="label">Label</label>
</div>
This is the html code Iused to try figure it out myself but just couldn't get it to work.
HTML:
<div class="container">
<input name="test" type="radio" class="radio" id="1">
<input name="test" type="radio" class="radio" id="2">
<input name="test" type="radio" class="radio" id="3">
<input name="test" type="radio" class="radio" id="4" checked>
<input name="test" type="radio" class="radio" id="5">
<label for="1" class="label active">Label</label>
<label for="2" class="label active">Label</label>
<label for="3" class="label active">Label</label>
<label for="4" class="label active">Label</label>
<label for="5" class="label">Label</label>
</div>
This is an example of how it should look like if radiobutton 4 were selected.