Ask coding questions

← Back to all posts
Append element in HTML and JS
dnilem26 (11)

Hey I'm trying to make a simple tasks website and when ever I append an element it doesn't appear

I know that the code is working because when you inspect element it is there but is never shown

If you figure out what is wrong please let me know

Thanks!

Answered by ch1ck3n (2309) [earned 5 cycles]
View Answer
Comments
hotnewtop
ch1ck3n (2309)

script.js:

tasks = []

function add(){
  task = document.querySelector('#addTask').value
  tasks.push(task)
  document.querySelector('#divTask').innerHTML += "<br>" + task
}

make sure to understand the code before pasting it in because you will have a hard time if you don't

oh yeah and remove the <form> </form> tags

dnilem26 (11)

@ch1ck3n OMG Thank you sooo much
I just realized that the h1's innerHTML where null

ch1ck3n (2309)

@dnilem26 ping me whenever you need more help! :)

dnilem26 (11)

@ch1ck3n k will do
and Thanks once again for being sooooooo helpful