const yazı = document.getElementsByTagName("input")[0]
let buton = document.getElementsByTagName("button")[0]
var kucuk = document.getElementsByClassName("little")[0]
buton.addEventListener("click", function(e) {
kucuk.innerHTML += `
<ul>
<li> ${yazı.value}<span></span></li>
</ul>
`
})
<div class="container">
<h2>a message you would like to pass</h2>
<button>submit</button>
<div class="little">
<input type="text" /><br />
</div>
</div>
It is like a simple Todo Project. The problem is when i click the button it prints the first value in the input everytime. And when i put the button to inside of the little class, it works only in first click nothing more. When i take button and input outside of the little class, it works properly. But i don't understand the core reason of that.