JavaScript實(shí)現(xiàn)鼠標(biāo)點(diǎn)擊導(dǎo)航欄變色特效
廢話不多說(shuō)了,直接給大家貼js實(shí)現(xiàn)鼠標(biāo)點(diǎn)擊導(dǎo)航欄變色代碼,具體代碼如下所示:
<!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>JAVASCRIPT之導(dǎo)航欄鼠標(biāo)點(diǎn)擊變色特效</title> <style type="text/css"> body { font-size:12px; font-family: Arial, Helvetica, sans-serif; } .ts_seled { color: #F00; } .ts_sel { color:#666; } </style> <script language="javascript"> window.onload = initLinkStyle; function initLinkStyle() { if(document.getElementsByName('myset')){ var arrLink = document.getElementsByName('myset'); for(i = 0; i < arrLink.length; i++) { var link = arrLink[i]; link.className='ts_sel'; link.onclick = clickNav; } } } /** * 執(zhí)行點(diǎn)擊事件 * @param {Object} event 鼠標(biāo)事件 */ function clickNav(event) { var target = event.currentTarget; //上次選擇的a的樣式 if(document.getElementsByName('myset')){ var arrLink = document.getElementsByName('myset'); for(i = 0; i < arrLink.length; i++) { var link = arrLink[i]; if(link.className == 'ts_seled') { link.className = 'ts_sel'; } } } target.className = 'ts_seled'; return false;//阻止瀏覽器默認(rèn)事件 } </script> </head> <body> <ul> <li> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" name="myset">首頁(yè)</a> </li> <li> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" name="myset">聯(lián)系我們</a> </li> <li> <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" name="myset">幫助</a> </li> </ul> </body> </html>
以上所述是小編給大家介紹的JavaScript實(shí)現(xiàn)鼠標(biāo)點(diǎn)擊導(dǎo)航欄變色特效,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
- JS中用三種方式實(shí)現(xiàn)導(dǎo)航菜單中的二級(jí)下拉菜單
- JS實(shí)現(xiàn)選中當(dāng)前菜單后高亮顯示的導(dǎo)航條效果
- 一個(gè)js控制的導(dǎo)航菜單實(shí)例代碼
- CSS3+Js實(shí)現(xiàn)響應(yīng)式導(dǎo)航條
- JS 實(shí)現(xiàn)導(dǎo)航欄懸停效果
- js實(shí)現(xiàn)移動(dòng)端導(dǎo)航點(diǎn)擊自動(dòng)滑動(dòng)效果
- js實(shí)現(xiàn)無(wú)限級(jí)樹(shù)形導(dǎo)航列表效果代碼
- js實(shí)現(xiàn)的常用的左側(cè)導(dǎo)航效果
- JavaScript實(shí)現(xiàn)滑動(dòng)導(dǎo)航欄效果
- 原生js實(shí)現(xiàn)波浪導(dǎo)航效果
相關(guān)文章
JavaScript基于libgif.js實(shí)現(xiàn)控制gif動(dòng)畫(huà)幀
這篇文章主要為大家詳細(xì)介紹了JavaScript如何利用libgif.js插件控制gif動(dòng)畫(huà)幀,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2024-02-02window.location.hash 屬性使用說(shuō)明
location是javascript里邊管理地址欄的內(nèi)置對(duì)象,比如location.href就管理頁(yè)面的url,用location.href=url就可以直接將頁(yè)面重定向url。而location.hash則可以用來(lái)獲取或設(shè)置頁(yè)面的標(biāo)簽值。2010-03-03Javascript調(diào)試腳本的經(jīng)驗(yàn)之談
隨著用JavaScript編程的深入,你會(huì)開(kāi)始理解那些JavaScript給出的不透明錯(cuò)誤信息。一旦你理解了你常犯的一般性錯(cuò)誤,你就會(huì)很快知道怎樣避免它們,這樣你寫(xiě)的代碼中的錯(cuò)誤將越來(lái)越少。2008-10-10