您好,登錄后才能下訂單哦!
廢話不多說(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)站的支持!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。