youroleksii Posted August 9, 2023 Share Posted August 9, 2023 (edited) Hi, trying to make the hyperlink on my page change color after a click on it with the code below. I am not sure where to insert it and where to insert a block ID to target the hyperlink. $('.item').click(function(){ $('div').removeClass('highlight'); $(this).addClass('highlight'); }); .highlight { color: red; } <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <section id="section"> <div class="item">Item 1</div> <div class="item">Item 2</div> <div class="item">Item 3</div> </section> Thanks in advance! Edited August 10, 2023 by youroleksii Link to comment
Solution Ziggy Posted August 9, 2023 Solution Share Posted August 9, 2023 You would have to add some tags and then add it all to a code block. <script> $('.item').click(function(){ $('div').removeClass('highlight'); $(this).addClass('highlight'); }); </script> <style> .highlight { color: red; } </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <section id="section"> <div class="item">Item 1</div> <div class="item">Item 2</div> <div class="item">Item 3</div> </section> tuanphan 1 Please like and upvote if my comments were helpful to you. Cheers! Zygmunt Spray Squarespace Website Designer Contact me: https://squarefortytwo.com Hire me on Upwork! 🔌 Ghost Squarespace Plugins (Referral link) 📈 SEO Space (Referral link) ⬛ SquareWebsites Plugins (Referral link) 🔲 SQSP Themes (Referral link) ✨ Spark Plugin (Referral link) 🖼️ Pinch-to-Zoom Gallery Lightbox Plugin (Referral link) ☕ Did I help? Buy me a coffee? Link to comment
youroleksii Posted August 9, 2023 Author Share Posted August 9, 2023 (edited) @Ziggy Where would I add tags and where would i place a code block? Thank you! Edited August 9, 2023 by youroleksii Link to comment
Ziggy Posted August 9, 2023 Share Posted August 9, 2023 10 minutes ago, youroleksii said: Where would I add tags and where would i place a code block? I added the script and style tags for you, see the code I shared. You can place it anywhere you want it. Please like and upvote if my comments were helpful to you. Cheers! Zygmunt Spray Squarespace Website Designer Contact me: https://squarefortytwo.com Hire me on Upwork! 🔌 Ghost Squarespace Plugins (Referral link) 📈 SEO Space (Referral link) ⬛ SquareWebsites Plugins (Referral link) 🔲 SQSP Themes (Referral link) ✨ Spark Plugin (Referral link) 🖼️ Pinch-to-Zoom Gallery Lightbox Plugin (Referral link) ☕ Did I help? Buy me a coffee? 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