There is three languages that are used to create web pages:
HTML, CSS, and JavaScript.
With keeping the three languages in separate files, HTML page is linking to CSS and JavaScript files.Each language forms a different purpose.
These three layers form the basis of a popular approach to building web pages called progressive enhancement.
HTML ONLY :The HTML layer allows you to focus on the most important thing about your site:
its content.HTML+CSS :The CSS rules works on how the page looks
away from the content itself.HTML+CSS+JAVASCRIPT :The JavaScript is added last
and enhances the users experience of interacting with the site.JavaScript is written in plain text, just like HTML and CSS,so you do not need any new tools to write a script.And to link it with the HTML :
Ex; add-content . j s <script> element to tell the browser it is coming across a script.<body>
<hl>Constructive & ; Co. </ hl>
<script src="js/ add-content.js"></ script>
<p>For all orders and i nquiries please cal l
<em>SSS-3344</ em></ p>
</ body>
It will be applied using document.write(object)
its usually work with the conditions command.
JAVASCRIPT RUNS WHERE IT IS FOUND IN THE HTML
It is best to keep JavaScript code in its own JavaScript file. JavaScript files are text files (like HTML pages and CSS style sheets), but they have the . j s extension.
The HTML
If you view the source code of the page in the browser, the JavaScript will not have changed the HTML, because the script works with the model of the web page that the browser has created.
Example of the Javascript commands: var today= new Date(); var hourNow = today.getHours(); var greeting; if (hourNow > 18) { greeting= ‘Good evening!’; else if (hourNow > 12) { greeting = ‘ Good afternoon!’; else if (hourNow > 0) { greeting = ‘Good morni ng!’; else { greeting = ‘Welcome! ‘ ; document .write( ‘ <h3>’ +greeting + ‘ </ h3> ‘);
STATEMENTS :Statement are instructionsand each one starts on a new line, and it can be organized into code blocks by surround it with curly braces ({});these are known as code blocks.
/* */ and its for multi-line comments .// and its for single-line comments.For example: var variable name = ‘variable value’; var age = ‘35’;
DATA TYPES : JavaScript distinguishes between numbers, strings, and true or false values known as Booleans.
USING A VARIABLE TO STORE A NUMBER :
For exampels : var price = 5; var quantity = 14;
For example : var username = ‘Molly’; var message = ‘See our upcoming range’;
For exampel: var title = “Molly’s Special Offers” ; var message = ‘<a href="sale .html">25% offl</a>’
For exampel: var i nStock = true; var shipping = = false;
For exampel: var price = 5; var quantity = 14; var total = price * quantity;
References:
@Jon Duckett/JAVASCRIPT