How to add JavaScript to a HTML Document?
Internal script
<script>
... JavaScript code goes here
</script>
Example:index.html
<!DOCTYPE html>
<html>
<head>
<title>Simple Page</title>
<script >
var n = 10;
alert(n);
</script>
</head>
<body>
</body>
</html>
External scripts
<script src="my_script.js"></script>
Example:index.html
<!DOCTYPE html> <html> <head> <title>Simple Page</title> <script src="my_script.js"></script> </head> <body> </body> </html>
var n = 10;
alert(n);
Comments
Post a Comment