I have been an avid reader on this platform, and I am hoping that my question has not already been addressed. I am struggling to find a solution to a problem I am facing.
There are two DIVs in my code that I toggle between showing and hiding using Javascript.
However, whenever the action is triggered, the page scrolls back to the top. Is there a way to keep the position intact? I have tried switching from visibility
to display = 'block' / 'none'
, but it did not make any difference.
This is the structure of my code:
The two divs that are affected by the script are popup1
and popup2
. They both have a position: fixed;
.
The element
class has viewport height.
I believe this information should be sufficient to troubleshoot the issue. If not, please feel free to ask for more details.
Thank you for your assistance!
UPDATE: You can view the JSFiddle here: https://jsfiddle.net/vx6vju3c/2/