Skip to content

Instantly share code, notes, and snippets.

@frendhisaido
Created July 24, 2021 17:55
Show Gist options
  • Save frendhisaido/e45d1a5bd09dce0356612349ec295c74 to your computer and use it in GitHub Desktop.
Save frendhisaido/e45d1a5bd09dce0356612349ec295c74 to your computer and use it in GitHub Desktop.
JDS BI_DEV_Javascript
function setup() {
// Write your code here.
const removeBtns = document.querySelectorAll('.remove');
removeBtns.forEach(el => el.addEventListener('click', event => {
event.target.parentElement.remove()
}));
}
// Example case.
document.body.innerHTML = `
<div class="image">
<img src="https://goo.gl/kjzfbE" alt="First">
<button class="remove">X</button>
</div>
<div class="image">
<img src="https://goo.gl/d2JncW" alt="Second">
<button class="remove">X</button>
</div>`;
setup();
document.getElementsByClassName("remove")[0].click();
console.log(document.body.innerHTML);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment