Having trouble creating three different buttons that toggle between various images using the CSS display property? Check out my code on https://jsfiddle.net/agt559e8/.
function USradarChange1() {
//document.getElementById("usradar1").src="weather/current-usradar.gif";
$('#USradarChangeButton1').click(function() {
$('#usradar1').css({ 'display': 'inline' });
$('#usradar2').css({ 'display': 'none' });
$('#usradar3').css({ 'display': 'none' });
});
}
function USradarChange2() {
//document.getElementById("usradar2").src="weather/usradar-an12hour.gif";
$('#USradarChangeButton2').click(function() {
$('#usradar1').css({ 'display': 'none' });
$('#usradar2').css({ 'display': 'inline' });
$('#usradar3').css({ 'display': 'none' });
});
}
function USradarChange3() {
//document.getElementById("usradar3").src="weather/usradar-an7day.gif";
$('#USradarChangeButton3').click(function() {
$('#usradar1').css({ 'display': 'none' });
$('#usradar2').css({ 'display': 'none' });
$('#usradar3').css({ 'display': 'inline' });
});
}
<div class="button-container">
<a class="button" id="USradarChangeButton1">Current US Radar</a>
<a class="button" id="USradarChangeButton2">US Radar 12 Hours</a>
<a class="button" id="USradarChangeButton3">US Radar 7 Days</a>
</div>
<div id="imgcontainer">
<img class="radar-img" id="usradar1" src="weather/current-usradar.gif" alt="Current US Radar">
<img class="radar-img" id="usradar2" src="weather/usradar-an7day.gif" alt="Current US Radar">
<img class="radar-img" id="usradar3" src="weather/usradar-an12hour.gif" alt="Current US Radar">
</div>
Need help figuring it out? Let me know your thoughts!