+ 4
Try to understand the error. It's saying, "can't read property value of null on line 13" means it can't find element with id "userName" and thus returns a null and hence the error.
And it's because, the JS part gets loaded before the HTML part and so it can't find the required element.
All you need to do is to wrap your entire JS code inside a function which will be called after the HTML window gets loaded.
You can do:
window.onload= function(){
//Your entire JS code goes here
}
+ 2
Jack sorry, didn't get you. What do you mean?
BTW, your above code is missing a '}' at line 24.
+ 2
Jack no, It should not if you could do it right. Kindly share the link of that broken code.



