Hanara Posted November 18 Posted November 18 Is it possible to make the class="list-item" act as a button or a clickable link if hover, maybe grabbing the button element. Here's the landing page: https://www.rpagroupllc.com/our-services-2 I am referring to this section:
Solution Lesum Posted November 18 Solution Posted November 18 @Hanara Hi! To make the list items clickable, you can add this code under Website > Pages > Website Tools > Code Injection > Header. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> <script> $(document).ready(function () { $('.user-items-list-item-container .list-item').each(function () { const button = $(this).find('.list-item-content__button'); const link = button.attr('href'); if (link) { $(this).css('cursor', 'pointer').on('click', function () { window.location.href = link; }); } }); }); </script> Note: This code will only work if the buttons inside the list items already have URLs linked to them. If my comments were useful, please like or mark my solution as answer so others can scroll to it quickly. Sam Web Developer & Digital Designer ☕ Did you find my contribution helpful? Buy me a coffee?
Hanara Posted November 20 Author Posted November 20 @Lesum. Thank you that perfectly works. May I know also the code please if it's a carousel. Here's the link: https://www.rpagroupllc.com/research-and-due-diligence And this is the section
Lesum Posted November 20 Posted November 20 @Hanara It's basically the same code; you just need to change one class name. Here's the code for auto list carousel: <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> <script> $(document).ready(function () { $('.user-items-list-carousel__slides .list-item').each(function () { const button = $(this).find('.list-item-content__button'); const link = button.attr('href'); if (link) { $(this).css('cursor', 'pointer').on('click', function () { window.location.href = link; }); } }); }); </script> If my comments were useful, please like or mark my solution as answer so others can scroll to it quickly. Sam Web Developer & Digital Designer ☕ Did you find my contribution helpful? Buy me a coffee?
Hanara Posted November 21 Author Posted November 21 @Lesum Yes, this works, but it depends on hovering over the button first. What I’m aiming for is that if a user hover over the carousel card will automatically make it act as a clickable link.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment