HaiderWaseem
KPCKevin Powell - Community
•Created by HaiderWaseem on 5/20/2024 in #front-end
Using createElement() outside the function
I'm trying to make a simple ToDo List. The problem I'm currently facing is that when I create the task span outside the function, and the function is called, the value of my input box is given to the span using innnerHTML, and it works fine, but when I click on 'Add Task' button again, it replaces the previous task and gets appended. However if I create the task span inside the function,(so that it is created every time the function is called),it works perfectly fine and gets added next to the previous task.
Link to my JSFiddle:
https://jsfiddle.net/5mqay9su/1/
13 replies