6月1日 childNodes vs children
childNodes 是 FF 而 children 是 IE 的用法
雖然這兩個用法上一樣 但是其實這裡面還是有些出入 FF的element.childNodes是element下所有的元素(Array)
而element.children 只又在 element 下一層而已
//test.js
//Switch Tab Effect
info=navigator.appName.toUpperCase();
function switchTab(tabpage,tabid){
if(info == "MICROSOFT INTERNET EXPLORER"){
var oItem = document.getElementById(tabpage);
for(var i=0;i var x = oItem.children(i);
x.className = "";
var y = x.getElementsByTagName('a');
y[0].style.color="#333333";
}
document.getElementById(tabid).className = "Selected";
var dvs=document.getElementById("cnt").getElementsByTagName("div");
for (var i=0;i if (dvs[i].id==('d'+tabid))
dvs[i].style.display='block';
else if(dvs[i].id.substring(0,4)=='dTab'){
dvs[i].style.display='none';
}
}
}
if (info == "NETSCAPE"){
var oItem = document.getElementById(tabpage);
for(var i=0;i if(oItem.childNodes[i].id!=null){
var node = oItem.childNodes[i];
node.className = "";
var y = node.getElementsByTagName('a');
y[0].style.color="#333333";
}
}
document.getElementById(tabid).className = "Selected";
var dvs=document.getElementById("cnt").getElementsByTagName("div");
for (var i=0;i if (dvs[i].id==('d'+tabid))
dvs[i].style.display='block';
else if(dvs[i].id.substring(0,4)=='dTab'){
dvs[i].style.display='none';
}
}
}
}
info=navigator.appName.toUpperCase();
function switchTab(tabpage,tabid){
if(info == "MICROSOFT INTERNET EXPLORER"){
var oItem = document.getElementById(tabpage);
for(var i=0;i
x.className = "";
var y = x.getElementsByTagName('a');
y[0].style.color="#333333";
}
document.getElementById(tabid).className = "Selected";
var dvs=document.getElementById("cnt").getElementsByTagName("div");
for (var i=0;i
dvs[i].style.display='block';
else if(dvs[i].id.substring(0,4)=='dTab'){
dvs[i].style.display='none';
}
}
}
if (info == "NETSCAPE"){
var oItem = document.getElementById(tabpage);
for(var i=0;i
var node = oItem.childNodes[i];
node.className = "";
var y = node.getElementsByTagName('a');
y[0].style.color="#333333";
}
}
document.getElementById(tabid).className = "Selected";
var dvs=document.getElementById("cnt").getElementsByTagName("div");
for (var i=0;i
dvs[i].style.display='block';
else if(dvs[i].id.substring(0,4)=='dTab'){
dvs[i].style.display='none';
}
}
}
}
留言
張貼留言