function showX()
document.getElementById("one").style.display = "block";
document.getElementById("two").style.display = "none";
document.getElementById("three").style.display = "none";
function showZ()
document.getElementById("one").style.display = "none";
document.getElementById("two").style.display = "block";
document.getElementById("three").style.display = "none";
function showY()
document.getElementById("one").style.display = "none";
document.getElementById("two").style.display = "none";
document.getElementById("three").style.display = "block";
div {display:inline;}
div img {width:400px;height: 400px;}
#one {
display: none;
}
#two {
display: none;
}
#three {
display: none;
}
<html>
<section id="one">
take this info es cool 1
</section>
<section id="two">
take this info es cool 2
</section>
<section id="three">
take this info es cool 3
</section>
</html>
当我点击我的图片时没有任何反应? 谁能帮帮我,好吗?
我已经尝试解决这个问题一段时间了,所以决定来这里。 在此先感谢您的帮助!
我是编程新手,我正在创建的网站元素需要这个。
我需要它,所以当我访问该网站时,它只会显示图片而不显示部分。单击图片时,它将显示第一部分,但隐藏其他部分。
最佳答案
您缺少大括号 {}
。这是工作。您还应该调用该函数。
function showX(){
document.getElementById("one").style.display = "block";
document.getElementById("two").style.display = "none";
document.getElementById("three").style.display = "none";
}
function showZ(){
document.getElementById("one").style.display = "none";
document.getElementById("two").style.display = "block";
document.getElementById("three").style.display = "none";
}
function showY(){
document.getElementById("one").style.display = "none";
document.getElementById("two").style.display = "none";
document.getElementById("three").style.display = "block";
}
showZ();
div {display:inline;}
div img {width:400px;height: 400px;}
#one {
display: none;
}
#two {
display: none;
}
#three {
display: none;
}
<html>
<section id="one">
take this info es cool 1
</section>
<section id="two">
take this info es cool 2
</section>
<section id="three">
take this info es cool 3
</section>
</html>
关于javascript - 使用 javascript 隐藏部分不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54816474/