$(function () { $(".tab").on("click", function () { const $this = $(this); const tabIndex = $this.closest("li").index(); // 현재 탭의 순서 (0부터 시작) $this.addClass("active").closest("li").siblings().find(".tab").removeClass("active"); $(".tab_content").eq(tabIndex).addClass("active").siblings(".tab_content").removeClass("active"); }); });