The problem seems to be you are executing the script before the element is loaded.
I assume this script is added in the hello.js
file which is added before the DOM is created.
The solution here is to execute the script after the DOM is ready like:
window.onload = function(){
document.getElementById("subm").onclick=function(){
alert("Hello WOrld");
}
}
All JavaScript code which deals with DOM elements like the one above has to be executed only after the DOM is loaded.
Demo: Fiddle