删除待办应用中的所有按钮

Delete all button in to do app

我尝试将所有添加删除到我的待办事项应用程序中。 我有这样的东西:

function removeAll(){
        var ol = document.getElementsByTagName('ol');
        if(ol.lenght > 0){
            ol.remove();
        }
    }
document.getElementById('delete-all').addEventListener('click', removeAll);

<input type="text" id="text-field">
<input type="button" id="add-task" value="dodaj zadanie!">
<input type="button" id="delete-all" value="usuń wszystko">

<div id="to-do-list-container">
    <ul id="task-list">
        <ol>damian</ol>
    </ul>
</div>

它没有显示任何错误...我检查带有 ol 标签的元素是否存在,然后尝试删除所有带有 ol 标签的元素。我试过 ol.parrentNode.remove();同样的效果...

使用 while 循环尝试以下操作:

function removeAll(){
  var list = document.getElementById("task-list");
  while(list.firstChild){
    list.removeChild(list.firstChild);
  }
}
document.getElementById('delete-all').addEventListener('click', removeAll);
<input type="text" id="text-field"/>
<input type="button" id="add-task" value="dodaj zadanie!"/>
<input type="button" id="delete-all" value="usuń wszystko"/>

<div id="to-do-list-container">
    <ul id="task-list">
        <ol>damian</ol>
        <ol>damian2</ol>
        <ol>damian3</ol>
    </ul>
</div>