Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
66 views
in Technique[技术] by (71.8m points)

javascript - Onclick event problems

I have an issue with my onclick event. I want to have a sub-menu within my page. I have 5 icons on my page. when I click on one icon, the other 4 icons disappear. when the 4 icons disappear, there will show up an couple of buttons to go to other pages.

my problem with this event is that the other buttons, don't show up. and i do not know what the problem is...

I made a video to show the problem;

https://youtu.be/F2NUj3KVIIk

my code;

<div id="column">
  <p id="afbeelding-spiraal">
    <img width="150" id="spiraal" src="https://www.spiralex.nl/wp-content/uploads/2020/12/spiraal-correct.png">
  </p>
</div>

<div id="column">
   <p id="afbeelding-plaat">
    <img width="150" id="plaat" src="https://www.spiralex.nl/wp-content/uploads/2020/12/platenwisselaar-correct.png">
   </p>
</div>

<div id="column">
  <p id="afbeelding-lucht">
    <img width="150" id="lucht" src="https://www.spiralex.nl/wp-content/uploads/2020/12/lucht-1.png">
  </p>
</div>

<div id="column">
   <p id="afbeelding-skids">
    <img width="150" id="skids" src="https://www.spiralex.nl/wp-content/uploads/2020/12/skids-correct.png">
   </p>
</div>

</div>


<div id="text">

<div id="text-buis">
    <button id="zwembadwarmtewisselaar">Zwembadwarmtewisselaar</button>
</div>
<script type="text/javascript">
var buis = document.getElementById("buis")
var spiraal = document.getElementById("spiraal")
var plaat = document.getElementById("plaat")
var lucht = document.getElementById("lucht")
var skids = document.getElementById("skids")

    buis.onclick = function(){
    if(spiraal.className ==""){
    
    spiraal.className = "hide";
    plaat.className = "hide";
    lucht.className = "hide";
    skids.className = "hide";
    zwembadwarmtewisselaar.className = "show";
question from:https://stackoverflow.com/questions/65881207/onclick-event-problems

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You need to make a reference to zwembadwarmtewisselaar also.
var zwembadwarmtewisselaar = document.getElementById("zwembadwarmtewisselaar");


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...