我想让我的图片和文字消失并显示在屏幕上。虽然它会消失,但一旦我隐藏了它,我就无法再次看到它。我该如何解决这个问题?
我的Javascript:
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.visibility == 'visible')
e.style.visibility = 'hidden'
else
e.style.visibility = 'visible'
}
在我的html模板中:
<a onclick="toggle_visibility('foo');"/>
<div id="foo" style="visibility:visible;" >
<img src="../static/image1.png"
style="left:17%;position:fixed;">
<div class="scrollBox"
style="font:12px;height:30%;width:55%;left:17%;position:fixed;overflow:auto;"/>
<p> text and stuff goes in here </p>
答案 0 :(得分:0)
你确实需要;&#39;
此外,您还需要点击一下。你的标签格式不正确。
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.visibility == 'visible')
e.style.visibility = 'hidden';
else
e.style.visibility = 'visible';
}
&#13;
<a onclick="toggle_visibility('foo');">Click Me</a>
<div id="foo" style="visibility:visible;" >
<img src="../static/image1.png"
style="left:17%;position:fixed;">
<div class="scrollBox"
style="font:12px;height:30%;width:55%;left:17%;position:fixed;overflow:auto;"/>
<p> text and stuff goes in here </p>
&#13;
答案 1 :(得分:0)