2017-04-26 61 views
-2

有沒有辦法將元素和實例傳遞給事件處理程序回調?如何在事件處理程序中訪問對象和元素

listNotes(key, value){ 
      this.allnotes.insertAdjacentHTML('beforeend', this.constructor.userNoteTemplate(key, value)) 
      this.totalNotes(); 
      let note = document.querySelector(`#note-${key}`); 
      note.addEventListener("click", this.deleteNote.bind(this)); 
    } 

deleteNote(){ 
     let instance = this; 
     let element = ?// I want the element details also 
    } 

回答

相關問題