Buttons not working

Hide all and show all buttons don’t work, cant’ find the solution:neutral_face::neutral_face:

<button onclick="hideAll()">Show all</button>
<button onclick="javascriptHide">Hide all</button>

Your hiding function is called hideAll(), but you are calling a nonexistent function above. Similarly your show all function is calling hideAll() while you do not have any routines to show all divs written.
I would recommend that you rethink the whole thing, avoid inline functions and start with basic JavaScript and algorithms section on FCC

Hello, @codeca423
Here is my solution to your buttons not working… hope it helps. This solution its a litlte longer but gets the job done, to your problem, you can do it in many ways also its endless, but this is to use you from scratch how to work this problem around, and hope someone else will share a better solution as well. here is my link to it. Hope it helps.


thanks alot men really good advice i will keep reading that section thanks

imendieta also thanks was very handy thank you

You do not have a Hide all button in the pen you reference. Were you wanting to hide all the buttons when clicking on the Show All button when any or all buttons are showing or did you mean to create another button?

Well anyway, here is another approach which would allow you to add 1000 content divs and corresponding buttons in the html section (with applicable class names) and not worry about changing the JavaScript section.


1 Like

thanks alot for that I manage to make it work in another way and even I did some design on it but now I cant make the “Extra bottom” show the right set of images that I assigned HERE

Hello there I have three that shows me different set of pics but with the last one that I just added “EXTRA BUTTON”
is not showing the right set of pic, is only showing the set of pics of the button before that one

What are you wanting to happen when a user clicks EXTRA BUTTON? If you are wanting to show the div with id=“content4”, then you are going to need another else if in your show function to handle content3.

thats true now its working perfect like you said I only needed to add one more else if

function show(dv){
   if(dv == '1'){
            document.getElementById("content1").style.display = "block";
   }else if(dv == '2'){
              document.getElementById("content2").style.display = "block";
   }else if(dv == '3'){
              document.getElementById("content3").style.display = "block";
        document.getElementById("content4").style.display = "block";

thanks alot