0 votes
107 views
in HTML by (3.5k points)
edited

How to include javascript code in HTML?

1 Answer

0 votes
by (3.5k points)
edited

There are two ways we can include javascript code in the HTML

  • Embedded Js: In this, we add the script tag directly in the HTML document as shown below:

<script> document. Write (“Welcome!”)</script>

Can add the script tag either in the head section of the body section of an HTML document depending on when you want the script to be loaded

  • External Js: create a separate javascript file and save it with .js extension and with the help of src attribute of script tag add the .js file to the HTML document as shown below:

<script src=”file1.js”></script>

Related questions

0 votes
1 answer 92 views
0 votes
1 answer 67 views
asked Jun 24, 2023 in HTML by Doubtly (98.9k points)
0 votes
1 answer 77 views
asked Jun 24, 2023 in HTML by Doubtly (98.9k points)
0 votes
1 answer 109 views
asked Aug 21, 2022 in HTML by codelikepro (3.5k points)
0 votes
1 answer 116 views
asked Jun 24, 2023 in HTML by Doubtly (98.9k points)
0 votes
1 answer 116 views
asked Jun 24, 2023 in HTML by Doubtly (98.9k points)

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

537 users

...