Skip to content

Instantly share code, notes, and snippets.

@IgorDePaula
Created September 25, 2023 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IgorDePaula/40a4cae52560aead37b6a5eed1a0b51b to your computer and use it in GitHub Desktop.
Save IgorDePaula/40a4cae52560aead37b6a5eed1a0b51b to your computer and use it in GitHub Desktop.
js troca pai pelo filho
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div class="card">
card 1 &nbsp;
<button id="teste">teste</button>
</div>
<div>
card 2
</div>
<script>
const button = document.querySelector("#teste")
button.addEventListener("click", () => {
const card = document.querySelector(".card:has(button)");
console.log(card)
card.innerHTML = "teste";
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment