Demo: https://tuanphan-demo01.squarespace.com/hover-text-change-video-v2?noredirect
Password: abc
Suppose you have 4 texts.
You want: when users hover on each text >> Change video on the right.
#1. First, add a Text Block with 4 Paragraph, then add these URLs
- Apple – #apple
- Microsoft – #microsoft
- Instagram – #instagram
- Google – #google
Make sure “Open Link in new tab” is DISABLED.
and 4 video blocks on the right
#2. Use this free tool to find the ID of Image and Video Blocks
In my example, we will have:
- Left text block: #block-81180abeb3d1bb243568
- Apple video: #block-6147b092aa559d47a4df
- Microsoft video: #block-8474988d8d52cc1d2334
- Instagram video: #block-0f4a6585a6c4af3b7f56
- Google video: #block-4b5750400e8336b00078
#3. Use this code to Code Injection – Footer (or Page Header Code Injection)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script> <script> $(document).ready(function(){ $("#block-6147b092aa559d47a4df").addClass("show"); // Apple $('#block-81180abeb3d1bb243568 a[href="#apple"]').hover(function(){ $("#block-6147b092aa559d47a4df").addClass("show"); $('div:not(#block-6147b092aa559d47a4df)').removeClass('show'); } ); // Microsoft $('#block-81180abeb3d1bb243568 a[href="#microsoft"]').hover(function(){ $("#block-8474988d8d52cc1d2334").addClass("show"); $('div:not(#block-8474988d8d52cc1d2334)').removeClass('show'); } ); // Instagram $('#block-81180abeb3d1bb243568 a[href="#instagram"]').hover(function(){ $("#block-0f4a6585a6c4af3b7f56").addClass("show"); $('div:not(#block-0f4a6585a6c4af3b7f56)').removeClass('show'); } ); // Google $('#block-81180abeb3d1bb243568 a[href="#google"]').hover(function(){ $("#block-4b5750400e8336b00078").addClass("show"); $('div:not(#block-4b5750400e8336b00078)').removeClass('show'); } ); }); </script> <style> #block-6147b092aa559d47a4df, #block-8474988d8d52cc1d2334, #block-0f4a6585a6c4af3b7f56, #block-4b5750400e8336b00078 { opacity: 0; transition: all 0.1s ease; } .show { opacity: 1 !important; transition: all 0.1s ease; } </style>
#4. Explain code