Skip to content

Instantly share code, notes, and snippets.

@thanapongp
Last active September 8, 2019 08:01
Show Gist options
  • Save thanapongp/e5936302b7c92f7ee77d71c8211141e3 to your computer and use it in GitHub Desktop.
Save thanapongp/e5936302b7c92f7ee77d71c8211141e3 to your computer and use it in GitHub Desktop.
app.js with deleteItem method added
import { htmlToElement } from './utils';
export default class App {
//...
addNewItem(itemName) {
//...
const item = htmlToElement(`
//...
`);
item.getElementsByClassName('delete-button')[0].addEventListener('click', () => this.deleteItem(item));
this.listRoot.appendChild(item);
this.input.value = '';
}
deleteItem(item) {
item.remove();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment