How do I make the code below not catch the elements <a>
with the attribute target="blank"
? Because location.href = link.href;
opens in the same card (only links with target="blank"
should open in a new card without animation).
document.addEventListener('click', function(event) {
if (event.target.tagName !== "A" || !event.target.href) return;
event.preventDefault();
var link = event.target;
document.body.style.opacity = 0;
document.body.addEventListener("transitionend", function() {
location.href = link.href;
});
});
If more clarification is needed, please comment below!