index.js
function HideOrShowFont(obj) {
if (obj == "a1") {
document.getElementById("a1").style.color = "#2577e3";
document.getElementById("a2").style.color = "#333";
document.getElementById("a3").style.color = "#333";
}
else if (obj == 'a2') {
document.getElementById("a1").style.color = "#333";document.getElementById("a2").style.color = "#2577e3";
document.getElementById("a3").style.color = "#333";
}
else if (obj == 'a3') {
document.getElementById("a1").style.color = "#333";
document.getElementById("a2").style.color = "#333";
document.getElementById("a3").style.color = "#2577e3";
}
}
index.html
<head>
<script type="text/javascript" src="../js/index.js"></script> //引入index.js文件
</head>
<body>
扫描二维码关注公众号,回复:
2209001 查看本文章
<ul id="ul1">
<li><a href="javascript:HideOrShowFont('a1')" id="a1">全部积分</a></li> /* id与js中的obj一致。与javascript:HideOrShowFont('a1') 中的a1一致*/
<li><a href="javascript:HideOrShowFont('a2')" id="a2">已使用</a></li><li><a href="javascript:HideOrShowFont('a3')" id="a3">已过期</a></li>
</ul>
<body>
效果图: