Estoy tratando de acceder a this.type en mi función activeTag(). Cuando hago clic en él, quiero agregar una clase personalizada a la etiqueta.
No puedo encontrar si es posible o si simplemente lo estoy haciendo mal.
export default class Tag { name; searchType; type; constructor(name, searchType, genre) { this.name = name; this.searchType = searchType; this.type= type; } tagDisplay() { const tag = document.createElement('li') tag.innerText = this.name; this.searchType.appendChild(tag); tag.addEventListener('click', this.activeTag) } activeTag() { console.log(this); //return the element I clicked on this.classList.add(this.type+'--selected'); //return undefined--selected }}