Path: csiph.com!aioe.org!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.javascript Subject: Re: Putting something into DOM without being visible Date: Thu, 02 Feb 2017 20:01:01 +0000 Organization: A noiseless patient Spider Lines: 22 Message-ID: <87h94cl5vm.fsf@bsb.me.uk> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="df9b8a2284473f75d1c1a4bbf4c6cfe4"; logging-data="18365"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+CWeoccmTf2AaTxmfwTOoD8LDBcKqGpsw=" Cancel-Lock: sha1:JVVGxPKGmK59YBoMUMkrCUUDiN8= sha1:mrvNUS7oYIZut99RnCjLOey99Y0= X-BSB-Auth: 1.d8ac1f5843fd7a6c1d81.20170202200101GMT.87h94cl5vm.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:32448 bit-naughty@hotmail.com writes: > If someone clicks a button, I want to download stuff with AJAX, and > then, I guess, append it to the DOM tree. But I DON'T want it to be > visible straightaway - I'll make it visible later. What do I do? You have lots of options. The simplest is probably to use "display: none" or "visibility: hidden". See [1] for the difference -- it's not clear which you mean. Other ways to hide elements (such as positioning them outside of the viewport) have too many problems to be worth recommending. To change the view you can switch the property directly on the elements (or on a container element), or you can use classes. Remember to consider the impact on accessibility if this is going to be used by others. [1] https://www.w3.org/TR/2011/REC-CSS2-20110607/propidx.html -- Ben.