批改状态:合格
老师批语:
<script>// 获取所有导航a标签const links = document.querySelectorAll('nav a');// 获取当前URL路径信息const path = location.pathname + location.search;links.forEach(function(item) {//console.log(path);//console.log(item.getAttribute('href'));// 检索href是否存在匹配项并添加高亮classif (path.indexOf(item.getAttribute('href')) !== -1) {item.classList.add('active');}})</script>
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号