本文實例講述了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 class="cotrs"><a href='javascript:' class="thisclass">首頁</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="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表格(table)操作技巧匯總》、《jquery中Ajax用法總結》、《jQuery常見經典特效匯總》、《jQuery動畫與特效用法總結》及《jquery選擇器用法總結》
希望本文所述對大家jQuery程序設計有所幫助。
新聞熱點
疑難解答