I've been trying to change the CSS class based on radio buttons and it does work, however it will only run once. E.g. If I select the white radio button then select oak, selecting white does nothing until a page refresh. I'm most certainly doing something wrong and any help would be appreciated.
$("#radio").on('change','input[type=radio]', (function() {
if($("#oakradio").is(":checked")) {
$("#over").removeAttr();
$('#over').addClass('oak');
}
else if($("#whiteradio").is(":checked")) {
$("#over").removeAttr();
$('#over').addClass('white');
}
else if($("#mocharadio").is(":checked")) {
$("#over").removeAttr();
$('#over').addClass('mocha');
}
}));
#over.mocha {
background-image: url("https://photography.bytebros.com.au/wp-content/uploads/sites/5/2017/09/pan_mocha.jpg");
background-repeat: no-repeat;
height: 515px;
width: 1190px;
margin: 0 auto 30px;
position: relative;
}
iframe {
height: 333px;
width: 1000px;
position: absolute;
top: 93px;
left: 93px;
}
#over.white {
background-image: url("https://photography.bytebros.com.au/wp-content/uploads/sites/5/2017/09/pan_white.jpg");
background-repeat: no-repeat;
height: 515px;
width: 1190px;
margin: 0 auto 30px;
position: relative;
}
#over.oak {
background-image: url("https://photography.bytebros.com.au/wp-content/uploads/sites/5/2017/09/pan_oak.jpg");
background-repeat: no-repeat;
height: 515px;
width: 1190px;
margin: 0 auto 30px;
position: relative;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="over" class="mocha">
<iframe src="http://photography.bytebros.com.au/wp-content/uploads/sites/5/2017/09/photo71000333.png"></iframe>
</div>
<form id="radio">
<input type="radio" name="color" value="white" id="whiteradio">White<br>
<input type="radio" name="color" value="oak" id="oakradio">Oak<br>
<input type="radio" name="color" value="mocha" id="mocharadio">Mocha<br>
</form>