tuanphan Posted March 7 Share Posted March 7 Demo: https://tuanphan3.squarespace.com/hover-image-show-video?noredirect Pass: abc Suppose you have 4 images. You want: when users hover on each image >> Change video on right. #1. First, add 4 Image Blocks on the Left and 4 Video Blocks on the Right #2. Use this free tool to find the ID of Image and Video Blocks https://chromewebstore.google.com/detail/squarespace-id-finder/igjamfnifnkmecjidfbdipieoaeghcff In my example, we will have Google Image: #block-yui_3_17_2_1_1709452007121_25573 Microsoft Image: #block-yui_3_17_2_1_1709452007121_26367 Apple Image: #block-yui_3_17_2_1_1709452007121_27254 Facebook Image: #block-yui_3_17_2_1_1709452007121_28340 Video 1: #block-yui_3_17_2_1_1709452007121_29414 Video 2: #block-yui_3_17_2_1_1709452007121_30480 Video 3: #block-yui_3_17_2_1_1709452007121_31549 Video 4: #block-yui_3_17_2_1_1709452007121_32617 #3. Use this code to Code Injection Footer (or Page Header Code Injection, page where you use Image Blocks, Video Blocks) <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script> <script> $(document).ready(function(){ // Apple $('#block-yui_3_17_2_1_1709452007121_27254').hover(function(){ $("#block-yui_3_17_2_1_1709452007121_29414").addClass("show"); }, function(){ $('#block-yui_3_17_2_1_1709452007121_29414').removeClass("show"); } ); // Microsoft $('#block-yui_3_17_2_1_1709452007121_26367').hover(function(){ $("#block-yui_3_17_2_1_1709452007121_30480").addClass("show"); }, function(){ $('#block-yui_3_17_2_1_1709452007121_30480').removeClass("show"); } ); // Facebook $('#block-yui_3_17_2_1_1709452007121_28340').hover(function(){ $("#block-yui_3_17_2_1_1709452007121_31549").addClass("show"); }, function(){ $('#block-yui_3_17_2_1_1709452007121_31549').removeClass("show"); } ); // Google $('#block-yui_3_17_2_1_1709452007121_25573').hover(function(){ $("#block-yui_3_17_2_1_1709452007121_32617").addClass("show"); }, function(){ $('#block-yui_3_17_2_1_1709452007121_32617').removeClass("show"); } ); }); </script> <style> #block-yui_3_17_2_1_1709452007121_29414, #block-yui_3_17_2_1_1709452007121_30480, #block-yui_3_17_2_1_1709452007121_31549, #block-yui_3_17_2_1_1709452007121_32617 { opacity: 0; transition: all 0.1s ease; } .show { opacity: 1 !important; transition: all 0.1s ease; } </style> #4. Explain code If you can't make code work, you can comment with your site url, I can help easier Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment