Unverified

Name

Hide Item when Another Appears

About

Any item/container with the ID 'Hex' will disappear from view when any item/container with 'Fex' appears in view.

Language

Javascript

Rating

Voted: 0 by 0 user(s)

How to Setup Snippet

Give your Item (let's say the Header Container Template) the ID = 'Hex'. Then give your Footer Template the ID = 'Fex'. Add this script into a HTML widget inside the Header Template. The Header container will disappear from view when the Footer appears.

Codevault

WebSquadron

Scroll down to see more snippets from this codevault.

Wordpress Compatability

The author has indicated that this snippet is compatable up to wordpress version: 6.4

Code Snippet Plugin Sync

Free & Pro

Download this snippet by clicking the download button, then head over to the Code Snippet Plugin settings in your wordpress admin dashboard, select the import menu then upload this file to import into your wordpress site.

Pro Only (Coming Soon)

You will be able to click a button and sync this snippet to your wordpress site automatically and from your dashboard manage all code snippets across all your wordpress sites that have the Code Snippets Pro plugin installed.

History

Last modified:

20/05/2024

Important Note

This snippet has the following status:

Unverified

This snippet has not been verified, use with caution and at your own risk. See details provided by author in sidebar and click below to find out more.

Hide Item when Another Appears

 
                    
1<script>
2document.addEventListener('DOMContentLoaded', function() {
3 // Get the header and footer elements
4 const header = document.querySelector('.Hex');
5 const footer = document.querySelector('.Fex');
6 
7 // Create an intersection observer
8 const observer = new IntersectionObserver((entries) => {
9 entries.forEach(entry => {
10 if (entry.isIntersecting) {
11 // Footer is in view, hide the header
12 header.style.display = 'none';
13 } else {
14 // Footer is not in view, show the header
15 header.style.display = 'block';
16 }
17 });
18 }, { threshold: 0 });
19 
20 // Start observing the footer
21 observer.observe(footer);
22});
23</script>

0

Related Snippets

Please see some snippets below related to this snippet..

General

Unverified

1

HTML: Metatag to Stop Zooming Mobile Forms

Added: 10 months ago

Last Updated: 10 months ago

<p>Prevents unhelpful zooming on forms for mobile devices</p>

General

AI Verified

4

WordPress Page/Post Revisions Limit

Added: 8 months ago

Last Updated: 5 months ago

Sets a cap on the number of revisions saved for both posts and pages in WordPress, helping to manage database storage efficiently. Adjust the number in the snippet to control the maximum revisions kep...

General

AI Verified

0

Custom Wordpress Register by User with Shortcode

Added: 1 year ago

Last Updated: 1 year ago

This script allows you to create an advanced and customizable registration form for your WordPress website. It includes fields for entering first name, last name, and email address, with the email add...

Other Snippets in this Codevault

These are some popular snippets from this users codevault..

Performance

AI Verified

32

Remove Unused Javascript

Added: 1 year ago

Last Updated: 3 days ago

Remove Unused Javascript - and improve your Page Speed Insight Score

WooCommerce

Pro Verified

10

Deactivate some WooCommerce Checkout Fields

Added: 1 year ago

Last Updated: 2 weeks ago

Deactivate some WooCommerce Checkout Fields from showing

Elementor

AI Verified

6

CSS Grid Aid

Added: 8 months ago

Last Updated: 1 month ago

This can be used for any WordPress Builder to aid working with CSS Grids.