jQuery实现点击后高亮背景固定显示的菜单效果【

这篇文章主要介绍了jQuery实现点击后高亮背景固定显示的菜单效果,可实现鼠标点击菜单项后呈现出鼠标滑过一样的背景高亮显示效果,同时该显示效果固定不变,需要的朋友可以参考下

本文实例讲述了jQuery实现点击后高亮背景固定显示的菜单效果。分享给大家供大家参考,具体如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>jquery实现点击后高亮背景的菜单特效</title> <style> *{ margin:0; padding:0; list-style:none;} body{ font:normal 14px/24px 'MicroSoft YaHei';} .cotrs{ width:960px; height:32px; line-height:32px; background:#999; margin:0 auto;} .cotrs a{ height:32px; line-height:32px; color:#fff; text-decoration:none; padding:0px 10px; display:block; float:left;} .cotrs a:hover{ text-decoration:none; background:#000;} .cotrs a.thisclass{text-decoration:none; background:#000;} </style> </head> <body> <br><br><br> <div> <a href='javascript:'>首页</a> <a href='javascript:'>菜单导航</a> <a href='javascript:'>时间日期</a> <a href='javascript:'>焦点图</a> <a href='javascript:'>tab标签</a> <a href='javascript:'>jquery特效</a> <a href='javascript:'>在线客服</a> <a href='javascript:'>广告代码</a> <a href='javascript:'>相册代码</a> <a href='javascript:'>图片特效</a> <a href='javascript:'>名站特效</a> <a href='javascript:'>其他代码</a> <a href='javascript:'>HTML5</a> </div> <script src="https://www.jb51.net/jquery-1.7.2.min.js"></script> <script> $(function(){ var cotrs = $(".cotrs a"); cotrs.click(function(){ $(this).addClass("thisclass").siblings().removeClass("thisclass"); }); }); </script> </body> </html>

运行效果图如下:

jQuery实现点击后高亮背景固定显示的菜单效果【

完整实例代码点击此处本站下载

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

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

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wzjdys.html