Answer the question
In order to leave comments, you need to log in
How to remove an element from an event?
Good day to all. I have this li, which is created in js:
task.innerHTML = `<b>${taskNameInput}</b><br/><i>${taskInput}</i><button class = 'item-btn'>Удалить</button>`
document.querySelector('.task-item').addEventListener('click', function(ev){
if (ev.target.tagName === 'LI' || 'B' || 'I' && ev.target.className != '.item-btn') {
alert('dfdf')
}
Answer the question
In order to leave comments, you need to log in
What's wrong?
item-btn
but no class .item-btn
({ target }) => {
if(target.closest('.item-btn')) {
return
}
// остальной код...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question