(Solved) How to include a javascript file in the HTML? [closed]


Perhaps your script reference is located in the HEAD section and the code looks for elements in the body which was not yet initialized.

Try wrapping your code in an onload event handler like this:

window.onload = function () {
    // Javascript code goes here
}

solved How to include a javascript file in the HTML? [closed]