Files
ClassContent/历届学生/刘合群/学校官网实战/js/index.js
2024-09-27 02:06:13 +08:00

31 lines
959 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(function() {
var tabTitle = (document.getElementsByClassName("tab-title")[0]).getElementsByTagName("li");
var tabContent = (document.getElementsByClassName("tab-content")[0]).getElementsByTagName("li");
/**
* index.js 和 swiper.js 中变量 i 冲突
* 1: 更换index.js中变量i的名称例如ff
* 2: (function(){ })() 自执行函数+闭包 防止变量污染
*/
// 第一次for循环主要作用是为了给标题绑定 onmousemove 事件
for(let i = 0;i<tabTitle.length;i++) {
tabTitle[i].onmousemove = function () {
// 第二次for是为了清除标题和内容的激活样式
for(let j = 0;j<tabTitle.length;j++) {
tabTitle[j].className = ""
tabContent[j].className = "tab-content-item"
}
// 为当前悬浮的对象设置 激活样式
tabTitle[i].className = "selected"
tabContent[i].className = "tab-content-item item-active"
}
}
})()