javascript 的问题...
发布网友
发布时间:2023-12-24 03:29
我来回答
共2个回答
热心网友
时间:2024-07-28 10:25
shubiao.style.background = "url(images/index_13.png)"; 中shubiao对象是一个数组,肯定替换不了的,把下面的替换掉你所有的js就可以了
window.onload = function(){
var shubiao = document.getElementById("ul_a").getElementsByTagName("li");
for (var nIdx = 0; nIdx < shubiao.length; nIdx++){
addEvent(shubiao[nIdx],'mouseover',jingguo);
addEvent(shubiao[nIdx],'mouseout',likai);
}
}
function jingguo( )
{
var oEvent = arguments[0];
var oTarget = oEvent.target || oEvent.srcElement;
oTarget.style.color = "red"; //修改为自己的图片路径
}
function likai( )
{
var oEvent = arguments[0];
var oTarget = oEvent.target || oEvent.srcElement;
oTarget.style.color = "#000";//修改为自己的图片路径
}
function addEvent(obj, evType, fn, useCapture){
if (obj.addEventListener){
obj.addEventListener(evType, fn, useCapture);
return true;
} else if (obj.attachEvent){
obj.attachEvent("on"+evType, fn);
return true;
} else {
appendAndPrint("Handler could not be attached");
return;
}
}
热心网友
时间:2024-07-28 10:26
function jingguo(i)
{
shubiao[i].style.background = "url(images/index_13.png)";
}
是这的问题吗?