1、头部JS
function hnShowNewsPic(num){
for(i=1;i<7;i++){
document.getElementById("hn_news_pic"+i).src = "images/normal.gif";
}
document.getElementById("hn_news_pic"+num).src = "images/active.gif";
}
2、页面HTML:
3、切换背景图片时的写法:
//错误写法
document.getElementById("hnTab"+num).style.backgroundImage = "images/hn_tab_hover.jpg";
//正确写法
document.getElementById("hnTab"+num).style.background = "url('images/hn_tab_hover.jpg')";
或:document.getElementById("hnTab"+num).style.backgroundImage = "url(images/hn_tab_hover.jpg)";