Programming Web Pages with JavaScript

Slides:



Advertisements
Similar presentations
Introduction to HTML & CSS
Advertisements

Sue Wills July Objects The JavaScript language is completely centered around objects, and because of this, it is known as an Object Oriented Programming.
HTML Overview - Cascading Style Sheets (CSS). Before We Begin Make a copy of one of your HTML file you have previously created Make a copy of one of your.
HTML 5 and CSS 3, Illustrated Complete Unit L: Programming Web Pages with JavaScript.
Lesson 12- Unit L Programming Web Pages with JavaScript.
© 2010 Delmar, Cengage Learning Chapter 9: Using ActionScript.
The Web Warrior Guide to Web Design Technologies
2440: 211 Interactive Web Programming JavaScript Fundamentals.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
Tutorial 10 Programming with JavaScript
Tutorial 13 Working with Objects and Styles. XP Objectives Learn about objects and the document object model Reference documents objects by ID, name,
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
Database-Driven Web Sites, Second Edition1 Chapter 3 INTRODUCTION TO CLIENT-SIDE SCRIPTS.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
Lab 3: Language Structures User Interface Lab: GUI Lab Sep. 9 th, 2014.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
1 JavaScript in Context. Server-Side Programming.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
Tutorial 10 Programming with JavaScript. XP Objectives Learn the history of JavaScript Create a script element Understand basic JavaScript syntax Write.
Tutorial 10 Programming with JavaScript
Done by: Hanadi Muhsen1 Tutorial 1.  Learn the history of JavaScript  Create a script element  Write text to a Web page with JavaScript  Understand.
Using Client-Side Scripts to Enhance Web Applications 1.
CS134 Web Design & Development Cascading Style Sheets (CSS) Mehmud Abliz.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
JavaScript Syntax, how to use it in a HTML document
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
XP Tutorial 8 Adding Interactivity with ActionScript.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2 Revised by Dr. T. Tran for CSI3140.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
JavaScript. JavaScript is the programming language of HTML and the Web. Easy to learn One of the 3 languages of all developers MUST learn: 1. HTML to.
JQuery JavaScript is a powerful language but it is not always easy to work with. jQuery is a JavaScript library that helps with: – HTML document traversal.
1 JavaScript in Context. Server-Side Programming.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
Chapter 10 Dynamic HTML (DHTML) JavaScript, Third Edition.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
JAVASCRIPT A quick review. True False ■The DOM is a standardized way of referring to parts of a Web page. ■TRUE ■In the DOM, attributes have their own.
XML DOM Week 11 Web site:
HTML5 and CSS3 Illustrated Unit C: Getting Started with CSS.
JavaScript and AJAX 2nd Edition Tutorial 1 Programming with JavaScript.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
XP Tutorial 10 New Perspectives on JavaScript, Comprehensive 1 Working with Dynamic Content and Styles Creating a Dynamic Table of Contents.
Getting Started with CSS
Javascript and Dynamic Web Pages: Client Side Processing
Unit M Programming Web Pages with
Chapter 6 JavaScript: Introduction to Scripting
Tutorial 10 Programming with JavaScript
Week 4: Introduction to Javascript
Concepts of HTML, CSS and Javascript
Unit M Programming Web Pages with
CGS 3066: Web Programming and Design Spring 2017
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
Website Design 3
Cascading Style Sheets - Building a stylesheet
Introduction to JavaScript
Objectives Insert a script element Write JavaScript comments
A second look at JavaScript
WEB PROGRAMMING JavaScript.
Introduction to Programming the WWW I
© 2015, Mike Murach & Associates, Inc.
Document Object Model (DOM): Objects and Collections
Structuring Content in a Web Document
Tutorial 10 Programming with JavaScript
Javascript and JQuery SRM DSC.
Introduction to JavaScript
Cascading Style Sheets - Building a stylesheet
CIS 136 Building Mobile Apps
Web Programming and Design
Presentation transcript:

Programming Web Pages with JavaScript

Objectives Explore the Document Object Model Access elements and properties using JavaScript Create statements Store and access data in variables HTML5 and CSS3 – Illustrated, 2nd Edition

Objectives (continued) Create a function Add an event listener Change CSS with JavaScript Create an if statement HTML5 and CSS3 – Illustrated, 2nd Edition

Explore the Document Object Model JavaScript: the most widely used programming language for modern web browsers Document Object Model (DOM): standardized way of referring to parts of a web page Creates a hierarchical arrangement known as a DOM tree Each part of HTML document represented by a node HTML5 and CSS3 – Illustrated, 2nd Edition

Explore the Document Object Model (continued) Object: HTML element in DOM Specific object must be identified in order to manipulate it using JavaScript Property: piece of a standard set of information associated with DOM node Attributes are considered their own nodes and are associated with their own properties HTML5 and CSS3 – Illustrated, 2nd Edition

Explore the Document Object Model (continued) Method: action that can be performed for a node Method names are followed by parentheses between which you specify information specific to the method querySelector() method lets you access any HTML element by specifying a CSS selector Example: querySelector("#nameinput") selects the element with the id value nameinput HTML5 and CSS3 – Illustrated, 2nd Edition

Explore the Document Object Model (continued) A DOM Tree HTML5 and CSS3 – Illustrated, 2nd Edition

Access Elements and Properties Using JavaScript querySelector() method lets you reference objects and properties querySelector() is a child of the Document object To use a method, specify its parent object, a period, and method name: document.querySelector() HTML5 and CSS3 – Illustrated, 2nd Edition

Access Elements and Properties Using JavaScript (continued) Specify CSS selector within parentheses of method to reference an object To select the aside element: document.querySelector("aside") To access a property, add dot and property name after method: document.querySelector("aside").textContent HTML5 and CSS3 – Illustrated, 2nd Edition

Access Elements and Properties Using JavaScript (continued) Console: part of developer tools in modern browsers; can be used to enter test code and view error messages related to JavaScript The browser console in Chrome: HTML5 and CSS3 – Illustrated, 2nd Edition

Create Statements Statement: a JavaScript instruction that performs an action: Assignment operator (=): Part of a statement that lets you assign a new property value Code on left of = accesses property Code on right of = specifies new value often enclosed in quotes HTML5 and CSS3 – Illustrated, 2nd Edition

Create Statements (continued) Every JavaScript statement ends with a semicolon (;) Statements created in external JavaScript file Text file with .js extension Referenced within HTML document using script element HTML5 and CSS3 – Illustrated, 2nd Edition

Create Statements (continued) Statements added to file: script element in HTML document: HTML5 and CSS3 – Illustrated, 2nd Edition

Store and Access Data in Variables Variables: Stored values you can access with a name you specify Can store many types of information Create with var keyword followed by name, equal sign, and value: HTML5 and CSS3 – Illustrated, 2nd Edition

Store and Access Data in Variables (continued) Shorter statements easier to work with Common to store object references as variables, then reference in other statements using variable names: HTML5 and CSS3 – Illustrated, 2nd Edition

Create a Function Function: Group of one or more statements with an assigned name Statements in function referenced as a single unit Create with function keyword, followed by name of function and () Statements enclosed in a single pair of braces {} HTML5 and CSS3 – Illustrated, 2nd Edition

Create a Function (continued) Function call: reference to a function name elsewhere in code to indicate when function should be executed Creating and calling a function: HTML5 and CSS3 – Illustrated, 2nd Edition

Add an Event Listener Events: actions commonly performed on a web page Can write JavaScript that responds to events Commonly used events: HTML5 and CSS3 – Illustrated, 2nd Edition

Add an Event Listener (continued) Event listener: a statement that specifies an object, an event, and function to call in response to event HTML5 and CSS3 – Illustrated, 2nd Edition

Change CSS with JavaScript Can use JavaScript to change element's CSS in response to event Create style rule using class selector, then use JavaScript to add/remove class values from element based on events: HTML5 and CSS3 – Illustrated, 2nd Edition

Create an if Statement operators: symbols to compare or change values of multiple objects or properties assignment operator (=) comparison operators: determine whether 2 values same or different if statement: compares 2 values; if result is true, statements are executed HTML5 and CSS3 – Illustrated, 2nd Edition

Create an if Statement (continued) Syntax for creating an if statement: Operators: HTML5 and CSS3 – Illustrated, 2nd Edition

Summary DOM is a standardized way of referring to parts of a web page The querySelector() method lets you reference objects and properties Script code is created by combining DOM objects, properties, and methods A statement is a JavaScript instruction that performs an action HTML5 and CSS3 – Illustrated, 2nd Edition

Summary (continued) The assignment operator lets you assign a new property value Variables are stored values you can access with a name you specify A function is a group of one or more statements with an assigned name A function must be called for its statements to be executed HTML5 and CSS3 – Illustrated, 2nd Edition

Summary (continued) An event listener is a statement that specifies an object, an event, and function to call in response to event You can use JavaScript to change the CSS for an element in response to an event An if statement compares 2 values and executes statements only if the comparison result is true HTML5 and CSS3 – Illustrated, 2nd Edition