- This topic has 5 replies, 2 voices, and was last updated 6 years ago by Tom.
-
AuthorPosts
-
April 3, 2018 at 1:06 pm #540186Mike
Hello,
My website https://gladstonevillagehall.org includes four lightweight grid columns with backgrounds and hyperlinked text within them. I am trying to allow the user to be able to click anywhere within the background and be taken to the link that the text contains. So far I have found the following JS able to do this,
<script> $("div.lgc-column:nth-child(1)").click(function() { window.location = $(this).find("a").attr("href"); return false; }); </script> <script> $("div.lgc-column:nth-child(2)").click(function() { window.location = $(this).find("a").attr("href"); return false; }); </script> <script> $("div.lgc-column:nth-child(3)").click(function() { window.location = $(this).find("a").attr("href"); return false; }); </script> <script> $("div.lgc-column:nth-child(4)").click(function() { window.location = $(this).find("a").attr("href"); return false; }); </script>
I am however struggling to impliment it. I have previously had it working, however after removing my smooth scrolling JS it is now refusing to work!
Do you have any suggestions on how I could either better go about achiving what I wish or do you know of a way to insert the JS code? I have tried various snippit plugins, nothing seems to be working.
Thanks,
MikeApril 3, 2018 at 10:05 pm #540512TomLead DeveloperLead DeveloperI would personally give each column a class (the same class), then do this:
<script> jQuery( document ).ready( function($) { $(".your-custom-class").click(function() { window.location = $(this).find("a").attr("href"); return false; }); } ); </script>
April 4, 2018 at 11:33 am #541219MikeHello Tom,
Thanks for that code, it works a treat! I added the same class to all of the columns and used your code, far more efficiant than four diffrent scripts!
On another note, have you any ideas on how I can tune my https://gladstonevillagehall.org website to get better performance? I was able to get the loading times really down on my company site https://hosker.tech by compressing images etc, however after trying all those steps for https://gladstonevillagehall.org it seems still very slow to load. Any ideas?
Thanks,
MikeApril 4, 2018 at 9:16 pm #541523TomLead DeveloperLead DeveloperPingdom is great for that. Check the file requests section here: https://tools.pingdom.com/#!/c38k3I/https://gladstonevillagehall.org/
It will tell you which files are taking the most time to load.
April 5, 2018 at 1:21 pm #542335MikeHello,
I suspect it may be the add this social widgets! Have to say, I am surprised at how much overhead they have, especially considering they are supposed to be developed professionaly.
Think I will try removing the add this plugin and see what performance diffrence it gives.
Thanks,
MikeApril 5, 2018 at 10:12 pm #542621TomLead DeveloperLead DeveloperThose kinds of plugins can be brutal when it comes to performance.
Glad I could help 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.