{"id":4696,"date":"2025-09-26T13:07:26","date_gmt":"2025-09-26T12:07:26","guid":{"rendered":"https:\/\/ibex.tech\/wordpress-sites\/?p=4696"},"modified":"2026-04-02T21:57:38","modified_gmt":"2026-04-02T20:57:38","slug":"hide-objects-and-sections-on-page-load","status":"publish","type":"post","link":"https:\/\/ibex.tech\/wordpress-sites\/page-builders\/elementor\/page-design\/hide-objects-and-sections-on-page-load","title":{"rendered":"Hide objects and sections on page load"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Default to all hidden<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>  \/\/----- HIDE ALL OPTIONAL WIDGETS AND SECTIONS OF THE PAGE INITIALLY -----\n  $HtmlOutput .= &lt;&lt;&lt;_END\n    &lt;style&gt;\n      #MyButton1,\n      #MyButton2 {\n        visibility: hidden;\n      }\n      #MySection1,\n      #MySection2 {\n        display: none;\n      }\n    &lt;\/style&gt;\n_END;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">To then display a section<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>  $HtmlOutput .= &lt;&lt;&lt;_END\n    &lt;script&gt;\n      document.addEventListener(\"DOMContentLoaded\", function(event)\n      {\n        document.getElementById('MySection1').style.display = 'flex';\n      });\n    &lt;\/script&gt;\n_END;<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Display it if it exists<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;script>\n  document.addEventListener(\"DOMContentLoaded\", function(event)\n  {\n    const el = document.getElementById('MySection1');\n    if (el)\n      el.style.display = 'flex';\n  });\n&lt;\/script><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Default to all hidden To then display a section Display it if it exists<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[354,385,347,349],"tags":[],"class_list":["post-4696","post","type-post","status-publish","format-standard","hentry","category-css","category-javascript","category-page-design","category-sections"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/posts\/4696","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/comments?post=4696"}],"version-history":[{"count":4,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/posts\/4696\/revisions"}],"predecessor-version":[{"id":4779,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/posts\/4696\/revisions\/4779"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/media?parent=4696"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/categories?post=4696"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/wordpress-sites\/wp-json\/wp\/v2\/tags?post=4696"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}