DYNAMIC WEBPAGES WITH JAVASCRIPT
CHAPTER 1/C - How Do I write a script for a WebPage
JavaScript is a scripting language to update and change both HTML and CSS. JavaScript can calculate, manipulate, and validate data on HTML pages. In Web development, Javascript can be used for changing the HTML content, HTML attribute values and HTML styles (CSS). Also, JS can be used for Hiding and Showing the HTML elements.
In HTML, JavaScript code is inserted between <script> and </script> tags. JavaScripts are placed in the <body>, or in the <head> section of an HTML page, or both. JavaScript runs where it is found in the HTML. The <script> in the HTML pages tells the browser to load the Javascript file which is similar to the <link> element used to load a CSS file. JavaScript can “display” data in 4 different ways: innerHTML, document.write(), window.alert() and console.log()
CHAPTER 2 - Basic Javascript Instructions (Pages 53-68 from Duckett)
** Statement** is a series of instructions that a computer can follow one-by-one. Each instruction or step is known as a Statement. Statements should end with semicolon ;. Comments inside the Javascript are important because it helps to understand and read the code easier. Two forward-slash // is used for single-line comment and /* */ is used for multi-line comment.
JavaScript Variables are containers for storing data values. Variables can be declared using the keyword called var. We can also assign a value to the variable var quantity = 3;. JavaScript variables can hold data types such as Numeric, Strings, and Boolean. Once the value is assigned to the variable, we can change the variable’s value in the same script.