Adding dynamic html to modal causes window to scroll up

Explanation: I have a modal that pops up when an html element is clicked. The modal is then appended to the document body and is positioned absolute. The top and left css attributes are set based of the element’s offset that was clicked to trigger the modal.

Problem: The modal fires properly and is positioned appropriately. There is a button within the modal that has a click function that adds further markup to the modal. When the button is pressed the markup is added correctly, but if the window is scrolled to any position, the window scrolls directly to the top.

What is the cause of the window scrolling and how can I prevent it from happening?

Thanks.

newest questions tagged jquery – Stack Overflow

About Admin