怎么把以下的代码整合在一起啊?
headtu[1].onmouseover = function (){
headtext[1].style.visibility="visible";
}
headtu[2].onmouseover = function (){
headtext[2].style.visibility="visible";
}
headtu[3].onmouseover = function (){
headtext[3].style.visibility="visible";
}
headtu[4].onmouseover = function (){
headtext[4].style.visibility="visible";
}
headtu[5].onmouseover = function (){
headtext[5].style.visibility="visible";
}
headtu[1].onmouseout = function (){
headtext[1].style.visibility="hidden";
}
headtu[2].onmouseout = function (){
headtext[2].style.visibility="hidden";
}
headtu[3].onmouseout = function (){
headtext[3].style.visibility="hidden";
}
headtu[4].onmouseout = function (){
headtext[4].style.visibility="hidden";
}
headtu[5].onmouseout = function (){
headtext[5].style.visibility="hidden";
}
我这样写了却不行。。。。
function showtext(k){
headtext[k].style.visibility="visible";
}
function hidtext(k){
headtext[k].style.visibility="hidden";
}
for(var k=1;k<6;k++){
headtu[k].onmouseover = function (){
showtext(k);
}
headtu[k].onmouseout = function (){
hidtext(k);
}
}
headtu[1].onmouseover = function (){
headtext[1].style.visibility="visible";
}
headtu[2].onmouseover = function (){
headtext[2].style.visibility="visible";
}
headtu[3].onmouseover = function (){
headtext[3].style.visibility="visible";
}
headtu[4].onmouseover = function (){
headtext[4].style.visibility="visible";
}
headtu[5].onmouseover = function (){
headtext[5].style.visibility="visible";
}
headtu[1].onmouseout = function (){
headtext[1].style.visibility="hidden";
}
headtu[2].onmouseout = function (){
headtext[2].style.visibility="hidden";
}
headtu[3].onmouseout = function (){
headtext[3].style.visibility="hidden";
}
headtu[4].onmouseout = function (){
headtext[4].style.visibility="hidden";
}
headtu[5].onmouseout = function (){
headtext[5].style.visibility="hidden";
}
我这样写了却不行。。。。
function showtext(k){
headtext[k].style.visibility="visible";
}
function hidtext(k){
headtext[k].style.visibility="hidden";
}
for(var k=1;k<6;k++){
headtu[k].onmouseover = function (){
showtext(k);
}
headtu[k].onmouseout = function (){
hidtext(k);
}
}