点击哪个哪个加边框
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>点击过的加边框,再点击还原</title> <style> a{text-decoration:none; color:#666666;} #nav ul{ list-style:none; float:left; text-align:right; margin-top: 18px; line-height: 42px; margin-left: -2px;} #nav ul li{ font-family:"微软雅黑","宋体"; font-size:14px; font-style:normal; font-weight:bold; letter-spacing:4px;} #nav ul li a:hover{ color:#666666;border:1px solid #F00;} .navdown a{ border:1px solid #F00;} </style> </head> <body> <div id="nav"> <ul> <li class="navdown"><a href="#"><span>网站首页</span></a></li> <li><a href="#"><span>关于我们</span></a></li> <li><a href="#"><span>新闻资讯</span></a></li> <li><a href="#"><span>产品展示</span></a></li> <li><a href="#"><span>客户案列</span></a></li> <li><a href="#"><span>联系我们</span></a></li> </ul> </div> </body> </html> <script type="text/javascript" src="https://files.cnblogs.com/files/heyiming/jquery-2.1.4.min.js"></script> <script type="text/javascript"> $(function(){ $("#nav li").click(function(){ $("#nav li").eq($(this).index()).addClass("navdown").siblings().removeClass("navdown"); }) }) </script>
效果图: