- Script in <head>....</head> section.
- Script in <body>....</body> section.
- Script in <body>....</body> and <head>....</head> section.
- Script in an external file and then include in <head>....</head> section.
If you want to have a script run on some event, such as when a user clicks somewhere, then you will place that script in the head as follows:
For example, you can keep following content in filename.js file and then you can use sayHello function in your Html file after including filename.js file:
Like our facebook page and subscribe with us to get our tutorial posts delivered directly to your emails. Also share this tutorial post on the various social media platforms available. Bye for now.