How do I discover which code is triggering a scroll to the top?

396 views Asked by At

This page: http://crossroadsphotographicworkshops.com/blog/blog-post-the-first/

I created the gallery, at the bottom. When a thumbnail is clicked, the lightbox opens, as expected, but the page behind it scrolls to the top. There is no # on my url. This doesnt happen on another site/theme. I assume this is caused by js in the parent theme. I've searched for scrolltop in the parent js, but no luck. I've looked in the dom of firebug, but dont really know what i'm looking for.

So, my question is, how do you inspect the events or targeted elements? How can you see all js attached to a given element? How can I figure out what is causing the scroll to top?

1

There are 1 answers

3
HC_ On BEST ANSWER
  • Assuming you are using Chrome, F12 for developer tools
  • Click on Sources tab
  • Expand Event Listener tab on the right and check everything that you think applies (or just everything)

try to nav through interactable elements and observe what happens in DOM Breakpoints on the righthand side of Sources tab as you go along.

If it doesn't work, inspect element the page to get the HTML and then right click the parent-most element (<html> or <body> tag) and at the bottom, set Break on to Subtree Modifications or whatever you think will work best, then re-interact with the site and observe what is called as it breaks.