我對這段代碼有一個小問題,jQuery('.nav-menu li:has(a[href="'+ window.location.pathname +'"])').addClass('active');它給了我這樣的結果:<li class="active"> <a href="/someUrl">Test</a> </li>但我想要這樣的東西: <li> <a href="/someUrl" class="active">Test</a> </li>有人可以幫我解決這個問題嗎?
將活動類添加到 href
慕姐8265434
2021-12-23 15:04:49