我正在使用此JavaScript来切换具有不同ID的某些div的可见性。它的工作原理我想要谷歌浏览器,甚至在互联网浏览器,但在Firefox中,当我悬停链接时,div不会改变其可见性。 的javascript:
function loaded() { // this one is called in the body tag
about.style.visibility='visible';
last = about;
}
function toggle_visibility(id) {
var e = document.getElementById(id);
if (last!=e) {
e.style.visibility = 'visible';
last.style.visibility='hidden';
last = e;
}
}
div的css:
#about {
background-color:#D580FE;
width:850px;
height:500px;
margin-left:auto;
margin-right:auto;
margin-top:40px;
}
#portofoliu {
background-color:#FF0000;
width:850px;
height:500px;
margin-left:auto;
margin-right:auto;
margin-top:-500px;
visibility:hidden;
}
答案 0 :(得分:0)
尝试从visibility:visible
和visibility:hidden
切换到display:block
和display:none
所以...
function loaded() { // this one is called in the body tag
about.style.display='block';
last = about;
}
function toggle_display(id) {
var e = document.getElementById(id);
if (last!=e) {
e.style.display = 'block';
last.style.display='none';
last = e;
}
}
div的css:
#about {
background-color:#D580FE;
width:850px;
height:500px;
margin-left:auto;
margin-right:auto;
margin-top:40px;
}
#portofoliu {
background-color:#FF0000;
width:850px;
height:500px;
margin-left:auto;
margin-right:auto;
margin-top:-500px;
display:none;
}
答案 1 :(得分:-1)
e
以外的其他变量。它在Firefox中用作window.event
变量。