I have a button on a page that, when clicked, loads another html file into a div in a "modal". For whatever reason, when I close the modal, the page seems to refresh and go back to the top.
function openNewWindow() {
$('.button').click(function(e) {
e.preventDefault();
$('body').addClass("noscroll");
$('#wrap').load('index.html');
return false;
});
}
openNewWindow();
$('.close-btn').click(function(e) {
e.preventDefault();
$("#wrap").empty();
$('body').removeClass("noscroll");
});
I have the preventDefault in place, but the "reload" seems to keep happening. Any issues with the script, and reason why this would be happening?
Link to my test page: http://andyrichardson.design/ajax/test.html