|
|
| JavaScript - Basics |
tutorial by Matt |
JavaScript is a very simple language to learn
once you know the basics. A lot of the sections on this site
will be very short because JavaScript is a broken up language.
We will cover the most important sections of the language
throughout these sections.
JavaScripts are placed in the html document usually in the
head section but it can also be placed in the body section
as well. To start a JavaScript you must use tag to
tell the browser that you are using javascript.
Then you set up your JavaScript Functions inside the script
tag and when your finished you close the script tag with just as you do with HTML.
If you want to print text using JavaScript you use:document.write("Hello, World!");
Now lets work with a very simple example.
Alert
You probably do not understand a lot of this and you won't until
later sections. In line 4 of the HTML Document you tell the
browser you are using a JavaScript. Then you declare a function
named alertme(). This function will display a small alert box
with the text "Hello!" in it. Next you close the function
and you close the JavaScript tag. Then in the body section
you start a form and you make a for button. In this button
there is something different from HTML, OnClick.
This is something you haven't heard about in HTML because
this is a JavaScript Event Handler. This tells the browser
that when this object is clicked do what is inside, which
calls javascript and the function.
Thats it for this lesson move on the next section...
Variables
|
|
|
|