Skip to content Skip to sidebar Skip to footer

Page Redirects To A Blank Link When Using Anchor Tag To Open A Modal

I am trying to open a modal window using the anchor tag. The modal window successfully opens. However, the page redirects to a random blank page upon opening the modal window. How

Solution 1:

You should probably use button to open a modal, but here's solution for your issue:

btn.onclick = function(event) {
  event.preventDefault(); // this will prevent default action
  modal.style.display = "block";
}

Solution 2:

replace you href tag with href="javascript:void(0)" and get the value through data-model

Post a Comment for "Page Redirects To A Blank Link When Using Anchor Tag To Open A Modal"