learning-journal

102-Learning journal

This project is maintained by cmboell

Dynamic Webpages With Javascript

Javascript and Jquery by Jon Duckett

Javascript is a computer programing language that you can write code that instructs the browser how to behave when the user is interacting with the app. JavaScript and jQuery can be used to access and manipulate the DOM, making the user’s experience dynamic and interactive.

Chapter 1c (pages 43-52)

There are 3 languages used to program web pages: HTML, CSS & Javascript. HTML is the content layer of the web page, CSS visually presents the page and Javascript is the layer that tells the page how to behave when a user interacts with it. All 3 are kept in separate files. These 3 layers working together are a popular approach used when building web pages called progressive enhancement.

Javascript files are generally kept in their own js file & have a .js extention at the end of the file name. To use a javascript with a web page, you use the <script> element in the HTML file to tell the browser it’s reading a script. It’s “src” attribute tells where it is stored.

Javascript example:

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 morning!';

} else {

greeting = 'Welcome!';

}

document.write('<h3>' + greeting + '</h3>');

Javascript can be added between two script tags, but that could also slow down your page, so that it why is it better to be kept in a separate file that the script tags on your html page just link to.

Chapter 2 (pages 53-69)

Back To Home Page