JSFiddle - React, Tailwind, and code Playground
by Leo Cavalcante
HTML
<a class="bg" href="https://google.com" target="_blank">
<form>
<button type="submit">CLICA AQUI</button>
</form>
</a>
CSS
.bg {
display: block;
background: black;
width: 100vw;
height: 100vh;
}
JavaScript
const bg = document.querySelector('.bg');
bg.addEventListener('click', function (event) {
if (event.target === bg) {
alert('Clicou no bg, redireciona');
return;
}
event.preventDefault();
alert('Clicou no botão');
})