01. Mails Delivery от 13 March 2022
Здравейте, получавам 63/100 и единия бутон Delete - този който е с клас "delete" не работи. Някой може ли да ми помогне ?
Благодаря :)
задача: https://judge.softuni.org/Contests/Practice/Index/3395#0
код:
function solve(){
let form = document.querySelector('form')
let listSection = document.getElementById('list')
let sentSection = document.querySelector('.sent-list')
let deleteSection = document.querySelector('.delete-list')
form.children[6].children[1].addEventListener('click', onReset)
function onReset(e){
e.preventDefault()
form.children[1].value = ''
form.children[3].value = ''
form.children[5].value = ''
}
form.children[6].children[0].addEventListener('click', onNext)
function onNext(e){
e.preventDefault()
if(!form.children[1].value || !form.children[3].value || !form.children[5].value) return
listSection.innerHTML = `<li>
<h4>Title: ${form.children[3].value}</h4>
<h4>Recipient Name: ${form.children[1].value}</h4>
<span>${form.children[5].value}</span>
<div id="list-action">
<button type="submit" id="send">Send</button>
<button type="submit" id="delete">Delete</button>
</div>
</li>
`
let newArr = [form.children[1].value, form.children[3].value, form.children[5].value]
form.children[1].value = ''
form.children[3].value = ''
form.children[5].value = ''
document.getElementById('send').addEventListener('click', onSend)
function onSend(e){
e.preventDefault()
sentSection.innerHTML = `<li>
<span>To: ${newArr[0]}</span>
<span>Title: ${newArr[1]}</span>
<div class="btn">
<button type="submit" class="delete">Delete</button>
</div>
</li>
`
listSection.innerHTML = ''
}
document.getElementById('delete').addEventListener('click', clearOne)
function clearOne(e){
e.preventDefault()
onDelete()
listSection.innerHTML = ''
}
document.querySelector('.delete').addEventListener('click', clearTwo)
function clearTwo(e){
e.preventDefault()
onDelete()
sentSection.innerHTML = ''
}
function onDelete(){
deleteSection.innerHTML = `
<li>
<span>To: ${newArr[0]}</span>
<span>Title: ${newArr[1]}</span>
</li>`
}
}
}
Много благодаря !