js小效果之根据对应项目名跳转

2022-07-15 20:27:19 浏览数 (1)

代码语言:javascript复制
<p><a href="http://192.168.2.61/pc/pc_MLMM/project.html?name=0">乳龄工程</a></p>
 <p><a href="http://192.168.2.61/pc/pc_MLMM/project.html?name=1">腹龄工程</a></p>
 <p><a href="http://192.168.2.61/pc/pc_MLMM/project.html?name=2">臀龄工程</a></p>
 <p><a href="http://192.168.2.61/pc/pc_MLMM/project.html?name=3">蜜龄工程</a></p>
 <p><a href="http://192.168.2.61/pc/pc_MLMM/project.html?name=4">康龄工程</a></p>



var url='http://192.168.2.61/pc/pc_MLMM/project.html';
var obj=[
    {name:'?name=0'},
    {name:'?name=1'},
    {name:'?name=2'},
    {name:'?name=3'},
    {name:'?name=4'},
    {name:'?name=5'}
]
for (let i = 0; i < obj.length; i  ) {
   if(url obj[i].name==window.location.href){
       console.log(i)
       $('.click-b li').eq(i).addClass("ss").siblings().removeClass("ss");
       $('.wrap li').eq(i).addClass('show').siblings().removeClass('show')
   }
}

更多内容请见原文,原文转载自:https://blog.csdn.net/weixin_44519496/article/details/120055883

0 人点赞