Firstly, my question might be foolish. sorry about that. I'm newbie.
I try to understand DOM. That's why I'm trying to make a shopping list.
At my shopping list, when I add an item to my list I try to add a class as well. Also every item has their own delete button. But problem is I couldn't do add a class to new item. My code is like that html
<div class="container">
<h1>Shopping List</h1>
<p>Please write your ingredients</p>
<input id="userinput" type="text" placeholder="Enter items">
<button id="enter">Enter</button>
<br>
<ul>
</ul>
</div>
and my javascript
var input = document.getElementById("userinput")
var ul = document.querySelector("ul");
function createListElement(){
var list = document.createElement("li");
list.appendChild(document.createTextNode(input.value));
ul.appendChild(list)
input.value ="";
document.getElementsByTagName("ul").setAttribute("class", "done");
var del = document.createElement("button");
del.appendChild(document.createTextNode("Delete"));
list.appendChild(del)
}