What is Java Script?
HTML to define the content of web pages
CSS to specify the layout of web pages
See Example J2.htm
All Example Files you can download from here
This example changes an HTML image, by changing the src attribute
See Example J3.html of an tag.
Changing the style of an HTML element, is a variant of changing an HTML attribute.
See Example J4.html
See Example J5.html
See Example J6.htm
See Example J7.html clicked
You can place an external script reference in <head> or <body> as you like. The script will behave as if it was located exactly where the <script> tag is located. External scripts cannot contain <script> tags
It separates HTML and code
Writing into an alert box, using window.alert().
Writing Writing into the HTML output using document.write().
Writing into an HTML element, using innerHTML.
Writing into the browser console, using console.log()
You can use an alert box to display data:
See Example J9.html
For testing purposes, it is convenient to use document.write():
See Example J10.html & j11.html
See Example J12.html
In your browser, you can use the console.log() method to display data. Activate t h e browser console wit h F12, an d select "Console " in the menu.
See Example J13.html
A computer program is a list of "instructions" to be "executed" by the computer.
In a programming language, these program instructions are called statements.
Java Script is a programming language
var x = 5;
var x = 5;
var y = 6;
var z = x + y;
Java Script Literas –
The most important rules for writing fixed values are: Numbers Numbers are written written with or without without decimals:
See Example J15.htm
Strings are text, written within double or single quotes:
See Example J16.html
Expressions can also represent fixed values:
See Example J17.html
var x; x = 6;
(5 + 6) * 10
See Example J18 html
var x = 5 + 6; var y = x * 10;
document.getElementById("demo").innerHTML = "Hello Dolly.";
This statement tells the browser to write " Hello Dolly. " inside an HTML element with id="demo":
See Example J19.html
See Example J20 html