Link to an anchor on a different page
-
Hi,
I’m not able to use anchors to scroll to a different sections of a page.
I think the problem is that in the code there isn’t any element with the anchor name.
I’ve tried to assign the ID to the row and to the element but it never shows in the html,
The website is under development and I can provide the access to the admin panel.
Thanks in advance
-
do you link to a different page and then to an anchor on that different page?
you can send the link to info@laytheme.com and please also send the url to this topic -
hey!
ok, I inserted this code in "lay options"→ "Custom <head> content
" and it works now:<script> //this is for making # links animate-scroll to a section that is on the same page jQuery(document).on( 'click', 'a[href^="#"]', function(e){ e.preventDefault(); var hash = jQuery(this).attr('href'); var el = jQuery(hash); var top = el.offset().top; jQuery('html, body').animate({ scrollTop: top }, 300, 'swing', function() { window.location.hash = hash; } ); } ); //this is for scrolling to a section of a different page when linking to it window.laytheme.on('newpageshown', function(){ var hash = window.location.hash; var el = jQuery(hash); if(el.length > 0) { var top = el.offset().top; window.scroll(0, top); } }); </script>
-
Great to hear!
Before you post:
- When using a WordPress Cache plugin, disable it or clear your cache.
- Update Lay Theme and all Lay Theme Addons
- Disable all Plugins
- Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"
This often solves issues you might run into
When you post:
- Post a link to where the problem is
- Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
- If the problem is difficult to explain, post screenshots / link to a video to explain it
Online Users
Forgot your key, lost your files, need a previous Lay Theme or Addon version?
Go to www.laykeymanager.com