jQuery實(shí)現(xiàn)的導(dǎo)航條點(diǎn)擊后高亮顯示功能示例
本文實(shí)例講述了jQuery實(shí)現(xiàn)的導(dǎo)航條點(diǎn)擊后高亮顯示功能。分享給大家供大家參考,具體如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>www.dbjr.com.cn jQuery導(dǎo)航條點(diǎn)擊后高亮顯示</title> <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></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() { // 為當(dāng)前點(diǎn)擊的導(dǎo)航加上高亮,其余的移除高亮 $(this).addClass('nav-active').siblings('li').removeClass('nav-active'); }); </script> </body> </html>
使用在線HTML/CSS/JavaScript代碼運(yùn)行工具:http://tools.jb51.net/code/HtmlJsRun測試上述代碼,運(yùn)行效果如下:
更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery切換特效與技巧總結(jié)》、《jQuery擴(kuò)展技巧總結(jié)》、《jQuery常用插件及用法總結(jié)》、《jQuery拖拽特效與技巧總結(jié)》、《jQuery常見經(jīng)典特效匯總》、《jQuery動(dòng)畫與特效用法總結(jié)》及《jquery選擇器用法總結(jié)》
希望本文所述對大家jQuery程序設(shè)計(jì)有所幫助。
相關(guān)文章
jquery 得到當(dāng)前頁面高度和寬度的兩個(gè)函數(shù)
得到當(dāng)前頁面高度和寬度的兩個(gè)函數(shù)2010-02-02JSON+Jquery省市區(qū)三級聯(lián)動(dòng)
這篇文章主要介紹了JSON+Jquery省市區(qū)三級聯(lián)動(dòng)的相關(guān)資料,需要的朋友可以參考下2016-01-01jQuery.validate.js表單驗(yàn)證插件的使用代碼詳解
Validate是基于jQuery的一款輕量級驗(yàn)證插件,內(nèi)置豐富的驗(yàn)證規(guī)則,這篇文章主要介紹了jQuery.validate.js表單驗(yàn)證插件的使用代碼詳解,需要的朋友可以參考下2018-10-10jquery ezUI 雙擊行記錄彈窗查看明細(xì)的實(shí)現(xiàn)方法
下面小編就為大家?guī)硪黄猨query ezUI 雙擊行記錄彈窗查看明細(xì)的實(shí)現(xiàn)方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-06-06使用jquery+CSS3實(shí)現(xiàn)仿windows10開始菜單的下拉導(dǎo)航菜單特效
本文是基于jquery和css3實(shí)現(xiàn)的仿windows10開始菜單的下拉導(dǎo)航菜單特效,代碼超簡單,感興趣的朋友一起看看吧2015-09-09多功能jQuery樹插件zTree實(shí)現(xiàn)權(quán)限列表簡單實(shí)例
這篇文章主要介紹了多功能jQuery樹插件zTree實(shí)現(xiàn)權(quán)限列表簡單實(shí)例,優(yōu)異的性能、靈活的配置、多種功能的組合,是樹插件zTree最大的優(yōu)勢,感興趣的小伙伴們可以參考一下2016-07-07