[ModernJS] Hello, World!

김민지·2022년 11월 5일

Learned


  1. The "script" tag
  2. External scripts

The "script" tag

  • JS programs can be inserted almost anywhere into an HTML document using the
<body>
	<script>
      alert('Hello, world!');
  	</script>
</body>

External scripts

  • We can put it into a separa file if we have a lot of JS code
  • Script files are attached to HTML with the src attribute
<script src="/path/to/script.js"></script>

Summary

  • We can use a script tag to add JavaScript code to a page
  • The type and language attributes are not required.
  • A script in an external file can be inserted with <script src="path/to/script.js" /script>.

Tasks


Q. Show an alert

Q. Show an alert with an external script

profile
노는게 제일 좋아

0개의 댓글