The 1st one is by placing the
<script> tag in the
<head> or in the
if you placed in the body make sure it's before the closing
<body>tag, so your scripts will run for all the elements in the body.
This way is not for daily use or for big projects, because the html file will be complicated more and more.
The 2nd is by creating a JS file and link it inside your HTML .
script.js and linked it using the
script tag. put the path to your JS file in the
The last way is the inline way. by adding an event listener inside any HTML element you want to run your scripts on.
SO the above code runs when the user clicks on the body
The common used way for daily programming is the External way
Oldest comments (0)