废话不多说了,直接给大家贴js实现鼠标点击导航栏变色代码,具体代码如下所示:
JAVASCRIPT之导航栏鼠标点击变色特效
body {
font-size:12px;
font-family: Arial, Helvetica, sans-serif;
}
.ts_seled {
color: #F00;
}
.ts_sel {
color:#666;
}
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= s_sel;
link.onclick = clickNav;
}
}
}
/**
* 执行点击事件
* @param {Object} event 鼠标事件
*/
function clickNav(event) {
var target = event.currentTarget;
//上次选择的a的样式