如何用jQuery编写点击导航条实现长尾词相关内容高亮显示的代码?

2026-04-09 00:232阅读0评论SEO问题
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计460个文字,预计阅读时间需要2分钟。

如何用jQuery编写点击导航条实现长尾词相关内容高亮显示的代码?

原文示例:原文:本文实例讲述了jQuery实现导航条点击后高亮显示功能。分享给大家供大家参考,具体如下:www.jb51.net jQuery导航条点击后高亮显示

改写后:jQuery实现导航点击高亮展示功能。分享供参考,内容如下:jQuery 导航点击高亮展示

本文实例讲述了jQuery实现的导航条点击后高亮显示功能。分享给大家供大家参考,具体如下:

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>www.jb51.net jQuery导航条点击后高亮显示</title> <script src="img.558idc.com/uploadfile/allimg/210605/1943445Q5-0.jpg"></script> <style> #nav li {float: left; width: 80px; text-align: center; list-style-type: none;} .nav-active {background: #ff47a5;} .nav-active a {color: #fff;text- decoration:none} </style> </head> <body> <ul id="nav"> <li class="nav-active"><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >首页</a></li> <li><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Page1</a></li> <li><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Page2</a></li> <li><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Page3</a></li> <li><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Page4</a></li> </ul> <script> $('#nav').find('li').click(function() { // 为当前点击的导航加上高亮,其余的移除高亮 $(this).addClass('nav-active').siblings('li').removeClass('nav-active'); }); </script> </body> </html>

使用在线HTML/CSS/JavaScript代码运行工具:tools.jb51.net/code/HtmlJsRun测试上述代码,运行效果如下:

更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery切换特效与技巧总结》、《jQuery扩展技巧总结》、《jQuery常用插件及用法总结》、《jQuery拖拽特效与技巧总结》、《jQuery常见经典特效汇总》、《jQuery动画与特效用法总结》及《jquery选择器用法总结》

如何用jQuery编写点击导航条实现长尾词相关内容高亮显示的代码?

希望本文所述对大家jQuery程序设计有所帮助。

本文共计460个文字,预计阅读时间需要2分钟。

如何用jQuery编写点击导航条实现长尾词相关内容高亮显示的代码?

原文示例:原文:本文实例讲述了jQuery实现导航条点击后高亮显示功能。分享给大家供大家参考,具体如下:www.jb51.net jQuery导航条点击后高亮显示

改写后:jQuery实现导航点击高亮展示功能。分享供参考,内容如下:jQuery 导航点击高亮展示

本文实例讲述了jQuery实现的导航条点击后高亮显示功能。分享给大家供大家参考,具体如下:

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>www.jb51.net jQuery导航条点击后高亮显示</title> <script src="img.558idc.com/uploadfile/allimg/210605/1943445Q5-0.jpg"></script> <style> #nav li {float: left; width: 80px; text-align: center; list-style-type: none;} .nav-active {background: #ff47a5;} .nav-active a {color: #fff;text- decoration:none} </style> </head> <body> <ul id="nav"> <li class="nav-active"><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >首页</a></li> <li><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Page1</a></li> <li><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Page2</a></li> <li><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Page3</a></li> <li><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Page4</a></li> </ul> <script> $('#nav').find('li').click(function() { // 为当前点击的导航加上高亮,其余的移除高亮 $(this).addClass('nav-active').siblings('li').removeClass('nav-active'); }); </script> </body> </html>

使用在线HTML/CSS/JavaScript代码运行工具:tools.jb51.net/code/HtmlJsRun测试上述代码,运行效果如下:

更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery切换特效与技巧总结》、《jQuery扩展技巧总结》、《jQuery常用插件及用法总结》、《jQuery拖拽特效与技巧总结》、《jQuery常见经典特效汇总》、《jQuery动画与特效用法总结》及《jquery选择器用法总结》

如何用jQuery编写点击导航条实现长尾词相关内容高亮显示的代码?

希望本文所述对大家jQuery程序设计有所帮助。