For context this was one of my first websites about 5 years ago and I decided to give each button its own individual id and change visibility for each individual element whenever the hide/show function was called. What? Why???
I did something really similar with all those buttons in the css file as well.
I could have put them all in the same div and hidden that instead or at least loop through them all, given that they all have numerical ids. Please don't trash your website like this.
You could make an array of those IDs, and iterate over them, instead? Maybe group those IDs by type of element, and concatenate them as appropriate. But that’s just my initial thought as a non-JS developer!
7
u/[deleted] Mar 24 '23
For context this was one of my first websites about 5 years ago and I decided to give each button its own individual id and change visibility for each individual element whenever the hide/show function was called. What? Why???
I did something really similar with all those buttons in the css file as well.
I could have put them all in the same div and hidden that instead or at least loop through them all, given that they all have numerical ids. Please don't trash your website like this.
7
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Mar 25 '23
Image Transcription: Code
[Any further code is cut off in the image.]
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
5
u/honken955 Mar 24 '23
that is great!!
4
u/nathena_19 Mar 25 '23
Now what is your solution for this? given them some class name like ”my-button” or else
2
u/Kunalopa Mar 25 '23
I wrote similar code in my early JS days. Respect for having the balls to show this
1
u/VirozPro Mar 25 '23
i don't know why people would use getElementById
1
u/dmitrychushov Mar 26 '23
I’m blind