jQuery實現(xiàn)的導航條點擊后高亮顯示功能示例
本文實例講述了jQuery實現(xiàn)的導航條點擊后高亮顯示功能。分享給大家供大家參考,具體如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>www.dbjr.com.cn jQuery導航條點擊后高亮顯示</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() {
// 為當前點擊的導航加上高亮,其余的移除高亮
$(this).addClass('nav-active').siblings('li').removeClass('nav-active');
});
</script>
</body>
</html>
使用在線HTML/CSS/JavaScript代碼運行工具:http://tools.jb51.net/code/HtmlJsRun測試上述代碼,運行效果如下:

更多關于jQuery相關內(nèi)容感興趣的讀者可查看本站專題:《jQuery切換特效與技巧總結》、《jQuery擴展技巧總結》、《jQuery常用插件及用法總結》、《jQuery拖拽特效與技巧總結》、《jQuery常見經(jīng)典特效匯總》、《jQuery動畫與特效用法總結》及《jquery選擇器用法總結》
希望本文所述對大家jQuery程序設計有所幫助。
相關文章
jQuery.validate.js表單驗證插件的使用代碼詳解
Validate是基于jQuery的一款輕量級驗證插件,內(nèi)置豐富的驗證規(guī)則,這篇文章主要介紹了jQuery.validate.js表單驗證插件的使用代碼詳解,需要的朋友可以參考下2018-10-10
jquery ezUI 雙擊行記錄彈窗查看明細的實現(xiàn)方法
下面小編就為大家?guī)硪黄猨query ezUI 雙擊行記錄彈窗查看明細的實現(xiàn)方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-06-06
使用jquery+CSS3實現(xiàn)仿windows10開始菜單的下拉導航菜單特效
本文是基于jquery和css3實現(xiàn)的仿windows10開始菜單的下拉導航菜單特效,代碼超簡單,感興趣的朋友一起看看吧2015-09-09
多功能jQuery樹插件zTree實現(xiàn)權限列表簡單實例
這篇文章主要介紹了多功能jQuery樹插件zTree實現(xiàn)權限列表簡單實例,優(yōu)異的性能、靈活的配置、多種功能的組合,是樹插件zTree最大的優(yōu)勢,感興趣的小伙伴們可以參考一下2016-07-07

