Ask coding questions

← Back to all posts
How to keep an element in the DOM but make it disappear from the page?
MikeJMS8910

So I have a script that created a lot of elements but I need a way of selecting a few at a time. How can I make it so that some elements are invisible(not with opacity because they still affect the page) but just have them so I can access them and make them visible when I need them. Thanks!

Answered by ruiwenge2 [earned 5 cycles]
View Answer
Voters
EpicCoderGuy1
MikeJMS8910
Comments
hotnewtop
ruiwenge2

do this in javascript:

ruiwenge2

replace ID OF ELEMENT with the element id

ruiwenge2

if you want to make it appear again use the following code: