Professional Documents
Culture Documents
Requirement
Install Visual Studio Code
Set Up
Create a folder on your desktop as the folder for your project.
Open the folder through the Visual Studio Code and create a file
with .html extension. After creating your file name, type “doc”
in and hit tab and save, and then you will have this lines of
codes:
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
</html>
This is the bare bone of the html file where we can start our
JavaScript program. First, is we have to create script tags
<script></script> inside the body tags, like this,
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
</script>
</body>
</html>
This is where we can store our JavaScript codes.
Hello Word
Inside the script tags, we will place our basic statement
together with the string “Hello World” or “Hello Philippines”,
like this:
console.log('Hello Philippines!');
To check if its running, right click the file name and select
Open in Default Browser (or in other browser, depending on what
other browser was installed in the computer). Or you can run the
file inside the folder you created on your desktop.
Alert Message
<script>
console.log('Hello Philippines!');
console.log('Hello Philippines!');
alert('Pree viet!');
</script>
console.log('Hello Philippines!');
alert('Mabuhay!')
Once codes have been created, save the file using the extension
“.js” . To check if the creation of the js file is successful, we
can check the desktop folder we have created. It should display
two files:
Input the following lines into the html body, assuming that the
name of the js file is home.
<body>
<script src="home.js"></script>
</body>
Variables
In Javascript, variables can only be described by a single data
type called “var”. This type covers both integers and string
data. Example:
var x = 'Jerome Macarilao';
var z = 10;
console.log('Hello ' + x);
console.log(z);
Document.GetElementbyID
To modify html website through Javascript, we can use the
getElementbyID command.
You can also use any header tag depending on your preference.
Prompt Command
var name = prompt ('What is you name?');
document.getElementById('sample').innerHTML = name;
youtube.com/watch?v=Qqx_wzMmFeA
to be continue from 15:50