Skip to content
Advertisement

Javascript – Hide all elements that do not have the specified ID

Hey there StackOverflow Community!

I’m fairly new to Stack and coding in general so this code will probably have an obvious error that I can’t figure out.

Basically, in the following code I want everything shown on screen that isn’t the element with the id settings to be hidden.

JavaScript

HTML:

JavaScript

Advertisement

Answer

JavaScript

You need to have a forloop! Update: You have to add an element tag DIV in order for it to work. Please see above.

It works for me: https://jsfiddle.net/bowtiekreative/j697okqd/1/

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement