I am trying to populate the div tag with what is typed in the name field (example below) using javascript. I am not sure what I am doing wrong but it is not working and I have at a loss as to why not?
All I want is when the user types their first name it appears below. I have looked at other examples and still confused why this one will not work.
hello whirled
Bla Bla
Answer
You are referencing the element before it is rendered. It is like trying to eat a pizza before you make it.
You need to attach the event after the element is rendered. Either window.onload, document ready, or add the script after the element in the markup.
hello whirled
Bla Bla
No comments:
Post a Comment