// Get a handle of the div element. var elem = document.getElementById("idDiv"); elem.innerHTML += "Hello World! <br>";
Next, we can directly source this file using the script tags. We are assuming that the "hello.js" file is in the same directory as that of the html file. Thus, the following example would also have the same "Hello World!" output.
In fact, this is how we include the location of jQuery library in a file.
When we load this page on a browser, then we would see the following text output in the browser.
varNum1 is 10 (type: number) varNum2 is 10.5 (type: number) varString is Nobel Prize (type: undefined) The type of objNobel is object Value of property name: Alfred Nobel Value of property invention: Dynamite