They assign a string to an object that should be an array. They use getAttribute('class') instead of element.classList.contains. They set the hidden attribute to a value, which won't work in every browser. They instead should add or remove the attribute.
This is the type of code I'd expect from someone who has no clue what they're doing.
So wait, it's bad that they used the hidden interface instead of manually modifying attributes, because browser support for it isn't good enough, but it's also bad that they manually modified attributes instead of using the classList interface, which has almost exactly the same level of support??
I mistakenly said that setting hidden to false won't work on every browser. I could have sworn I saw that in action at some point, but I'm not finding any resource that backs up my claim
108
u/matt1484 if true else false Sep 21 '21
With code like that, his employment status is about to be set to
notVisibility25
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Sep 21 '21
Image Transcription: Code
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
18
u/account_is_my_alt Sep 21 '21
what is the best way to hide a card?
11
u/Character_Medical Sep 22 '21
And I'm more interested to know who hurt your friend in childhood 🤔
4
u/Blueson Sep 22 '21
Something that surprises me with code like this is that you almost have to have some kind of basic knowledge of JS/HTML?
I mean, if I google "How to hide div with javascript" none of the examples will be this bad.
So how do you even figure out how to write this mess without knowing how to do it the simple and better way?
3
u/HunterRbx Sep 22 '21
$(“.stuff”).hide()
1
u/Wiwwil Sep 22 '21
We all started somewhere. I remember my early JS / jQuery code. I came a long way.
1
u/Tomekske Sep 22 '21
Solution: don't use javascript