Last active
September 8, 2019 08:01
-
-
Save thanapongp/e5936302b7c92f7ee77d71c8211141e3 to your computer and use it in GitHub Desktop.
app.js with deleteItem method added
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
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