再會(huì)!我是 jQuery 新手。請(qǐng)問如何循環(huán)遍歷按鈕,以便在單擊按鈕時(shí)僅顯示其內(nèi)容,并在每次單擊時(shí)更改按鈕上的活動(dòng)類。我為另外兩個(gè)按鈕重復(fù)了下面的代碼:$("#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");})僅將活動(dòng)類添加到單擊的按鈕不起作用。$("#subsidiary-btns .subsidiary-btn").on("click", () => { $("button.subsidiary-btn").removeClass("subsidiary-btn-active"); $(this).addClass("subsidiary-btn-active");})謝謝
jQuery-循環(huán)按鈕添加點(diǎn)擊時(shí)的活動(dòng)類
ITMISS
2023-08-05 19:39:27