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

0

Insert CSV file data to a list

Added: 6 months ago

Last Updated: 6 months ago

General

Unverified

0

Body Class "scroll" on scroll

Added: 6 months ago

Last Updated: 4 months ago

General

AI Verified

0

Cerrar sesion - cliente

Added: 5 months ago

Last Updated: 5 months ago

Other Snippets in this Codevault

These are some popular snippets from this users codevault..

Performance

AI Verified

31

Remove Unused Javascript

Added: 1 year ago

Last Updated: 1 month 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: 1 week ago

Deactivate some WooCommerce Checkout Fields from showing

Elementor

AI Verified

6

CSS Grid Aid

Added: 7 months ago

Last Updated: 1 month ago

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