tuanphan Posted November 21 Posted November 21 If you have an accordion block like this. You want when clicking on each accordion item >> change image on right. You can follow these steps #1. First, add an Accordion Block and 3 Image Blocks on Right. #2. Find ID of 4 Blocks. In my example, it is: Accordion Block: #block-yui_3_17_2_1_1732105464935_11135 Image 01: #block-yui_3_17_2_1_1732180734113_17966 Image 02: #block-2c21a42595311ecfc9af Image 03: #block-290c4e18907fa00a0391 #3. Use this code to Code Injection - Footer (or Page Header Injection) <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> <script> $(document).ready(function () { const blocks = [ "#block-yui_3_17_2_1_1732180734113_17966", "#block-2c21a42595311ecfc9af", "#block-290c4e18907fa00a0391" ]; $(blocks.join(", ")).hide(); $(blocks[0]).show(); $("li.accordion-item").on("click", function () { const index = $(this).index(); $(blocks.join(", ")).hide(); $(blocks[index]).show(); }); }); </script> #4. Result 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!)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment