https://i.sstatic.net/R7Yc4.pngHey there! I'm a beginner when it comes to jQuery. Can someone please guide me on how to loop through buttons, display their contents when clicked, and update the active class each time a button is clicked?
I have duplicated the code below for two additional buttons:
$("#member-company-btn").on("click", () => {
$("#member-company-content").show("slow");
$("#group-company-content").hide("slow");
$("#abuja-sub-company-content").hide("slow");
$("#lagos-sub-company-content").hide("slow");
})
$("#group-company-btn").on("click", () => {
$("#member-company-content").hide("slow");
$("#group-company-content").show("slow");
$("#abuja-sub-company-content").hide("slow");
$("#lagos-sub-company-content").hide("slow");
})
However, my attempt to add an active class only to the clicked button did not work as expected.
$("#subsidiary-btns .subsidiary-btn").on("click", () => {
$("button.subsidiary-btn").removeClass("subsidiary-btn-active");
$(this).addClass("subsidiary-btn-active");
})
Thank you!