Let's say we have a set of 12 div tags, each representing a different month. Whenever one of these divs is clicked on, it should display the corresponding content for that specific month while hiding all other months' content.
All 12 month divs share the common class month
. The sections containing content for each month share the class month_section
, with their individual month names as unique identifiers.
This is the current state of my JavaScript code:
$("#January,#February,#March,#April").click(function(e)){
$(".month").removeClass("highlight");
$(".month_sections").removeClass("show");
$(".month_sections").addClass("hide");
if(this == "#January"){(this).addClass("highlight");$(".january").addClass("show");}
else if(this == "#February"){(this).addClass("highlight");$(".february").addClass("show");}
else if(this == "#March"){(this).addClass("highlight");$(".march").addClass("show");}
else if(this == "#April"){(this).addClass("highlight");$(".april").addClass("show");}
});
However, the if statement doesn't seem to be functioning correctly.