我正在創建一個基本的待辦事項列表,輸入字段似乎將所有輸入的數據保存為下拉列表,但我無法修復它。我嘗試過使用 .reset() fn 以及此處顯示的其他選項,例如使用val("") 或 val(0) 似乎沒有任何作用。所以任何人都可以建議我如何解決這個問題。我也嘗試過 return fn 和 val 函數,但它仍然不起作用。提前致謝。? ? const addForm = document.querySelector('.add');? ? const todolst = document.querySelector('.todolst');? ? const deletelst = document.querySelector('.delete')? ? const task = addForm.add.value.trim();? ? const newTemplate = task => {? ? ? const html =? ? ? ? <li class="list-group-item d-flex justify-content-between align-items-center"><span>${task}</span><i class="far fa-trash-alt delete"></i></li>? ? todolst.innerHTML += html? ? }? ? // to add a tag? ? ?addForm.addEventListener('Enter', e => {? ? ?e.preventDefault();? ? ? if (task.length) {? ? ? ? newTemplate(task);? ? ? ? addForm.val(0);? ? ? }? ? });[enter image description here]
僅使用 javascript 清除表單下拉列表
滄海一幻覺
2023-07-06 19:54:04