{"id":4317,"date":"2025-05-13T15:16:48","date_gmt":"2025-05-13T14:16:48","guid":{"rendered":"https:\/\/ibex.tech\/javascript\/?p=4317"},"modified":"2025-08-09T17:35:50","modified_gmt":"2025-08-09T16:35:50","slug":"hide-a-section-of-the-page","status":"publish","type":"post","link":"https:\/\/ibex.tech\/javascript\/manipulating-html\/hide-a-section-of-the-page","title":{"rendered":"Hide a section of the page"},"content":{"rendered":"\n<p>Use .style.display = just make sure when you show it you are using \u2018flex&#8217; and not \u2018inline\u2019 if the element is a flex!<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Hide it:<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>  document.getElementById('MyId').style.display = 'none';<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Show it<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>  document.getElementById('MyId').style.display = 'inline';\n\/\/or\n  document.getElementById('MyId').style.display = 'flex';<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">To hide a section with id=pageheader&#8221;<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>  &lt;script&gt;\n    \/\/Hide section when the page loads\n    document.addEventListener(\"DOMContentLoaded\", function() {\n        var header = document.getElementById(\"page-header\");\n        if (header) {\n            header.style.display = \"none\";\n        }\n    });\n  &lt;\/script&gt;<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Display it again<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>  header.style.display = 'inline';\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Use .style.display = just make sure when you show it you are using \u2018flex&#8217; and not \u2018inline\u2019 if the element is a flex! Hide it: Show it To hide a section with id=pageheader&#8221; Display it again<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[132,74],"tags":[],"class_list":["post-4317","post","type-post","status-publish","format-standard","hentry","category-manipulating-css","category-manipulating-html"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/posts\/4317","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/comments?post=4317"}],"version-history":[{"count":3,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/posts\/4317\/revisions"}],"predecessor-version":[{"id":4336,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/posts\/4317\/revisions\/4336"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/media?parent=4317"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/categories?post=4317"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/javascript\/wp-json\/wp\/v2\/tags?post=4317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}