I haven't got much experience in javascript. But I got a little slider and a lightbox, whose content should change when a specific radio is selected. So for example when the radio with id="id2"
is selected, the content of the lightbox
<div class="modal">
<div class="modal__inner">
<label class="modal__close" for="modal-1"></label>
<img src="img/blabla.JPG">
<p>blablabla</p>
</div>
</div>
should be "blabla"
and the source of the image "img/blabla.jpg"
.
But now when I select the 2nd radio with id="id3"
, the content should be "blopblop"
and the source of the image "img/blopblop.jpg"
...
Is that possible?
I already got a code on my website, which changes the href
of a link when a specific radio is selected:
function myFunction() {
if(document.getElementById('id2').checked) {
document.getElementById('myLink').href = "infografik.html";
}
But I don't know how I should do it with "p
" and "img
"...
Thanks for your help!