Created
September 25, 2023 15:00
-
-
Save IgorDePaula/40a4cae52560aead37b6a5eed1a0b51b to your computer and use it in GitHub Desktop.
js troca pai pelo filho
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Title</title> | |
</head> | |
<body> | |
<div class="card"> | |
card 1 | |
<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