谁帮忙把下面一段代码用一个函数调用写出来,在网页是要用到doclick1()-doclick10()下面这样的函数要写10几个,我想用switch case
再写一个函数, 这样就简单了
function doClick1(o){
o.className="taba";
var z;
var id;
var a;
for(var i=1;i<=2;i++){
id ="aa"+i;
z = document.getElementById(id);
a = document.getElementById("a"+i);
if(id != o.id){
z.className="tabb";
a.style.visibility = "hidden";
}else{
a.style.visibility = "visible";
}
}
}
function doClick2(o){
o.className="taba";
var z;
var id;
var b;
for(var i=1;i<=2;i++){
id ="bb"+i;
z = document.getElementById(id);
b = document.getElementById("b"+i);
if(id != o.id){
z.className="tabb";
b.style.visibility = "hidden";
}else{
b.style.visibility = "visible";
}
}
}
function doClick3(o){
o.className="taba";
var z;
var id;
var c;
for(var i=1;i<=2;i++){
id ="cc"+i;
z= document.getElementById(id);
c= document.getElementById("c"+i);
if(id != o.id){
z.className="tabb";
c.style.visibility = "hidden";
}else{
c.style.visibility = "visible";
}
}
}
function doClick4(o){
o.className="taba";
var z;
var id;
var d;
for(var i=1;i<=2;i++){
id ="dd"+i;
z = document.getElementById(id);
d = document.getElementById("d"+i);
if(id != o.id){
z.className="tabb";
d.style.visibility = "hidden";
}else{
d.style.visibility = "visible";
}
}
}
function doClick5(o){
o.className="taba";
var z;
var id;
var e;
for(var i=1;i<=2;i++){
id ="ee"+i;
z = document.getElementById(id);
e = document.getElementById("e"+i);
if(id != o.id){
z.className="tabb";
e.style.visibility = "hidden";
}else{
e.style.visibility = "visible";
}
}
}
function doClick6(o){
o.className="taba";
var z;
var id;
var f;
for(var i=1;i<=2;i++){
id ="ff"+i;
z = document.getElementById(id);
f = document.getElementById("f"+i);
if(id != o.id){
z.className="tabb";
f.style.visibility = "hidden";
}else{
f.style.visibility = "visible";
}
}
}
function doClick7(o){
o.className="taba";
var z;
var id;
for(var i=1;i<=2;i++){
id ="gg"+i;
z = document.getElementById(id);
g = document.getElementById("g"+i);
if(id != o.id){
z.className="tabb";
g.style.visibility = "hidden";
}else{
g.style.visibility = "visible";
}
}
}
function doClick8(o){
o.className="taba";
var z;
var id;
for(var i=1;i<=2;i++){
id ="hh"+i;
z = document.getElementById(id);
h = document.getElementById("h"+i);
if(id != o.id){
z.className="tabb";
h.style.visibility = "hidden";
}else{
h.style.visibility = "visible";
}
}
}