Review IDIA 619 Spring 2013 Bridget M. Blodgett. HTML A basic HTML document looks like this: Sample page Sample page This is a simple sample. HTML user.

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Modifying existing content Adding/Removing content on a page using jQuery.
Lesson 12- Unit L Programming Web Pages with JavaScript.
Chapter 20 Thinking Big: Functions. Copyright © 2006 Pearson Addison-Wesley. All rights reserved Anatomy of a Function Functions are packages for.
Information Technology Center Hany Abdelwahab Computer Specialist.
Introduction to JavaScript for Python Programmers
JAVASCRIPT Introduction Kenny Lam. What is Javascript?  Client-side scripting language that can manipulate elements in the DOM  Event-driven language.
JQuery. What is jQuery? jQuery is a fast, small, and feature-rich JavaScript library that simplifies HTML document traversing and manipulation event handling.
Intro to HTML5 IDIA 619 Spring 2013 Bridget M. Blodgett.
JQuery and Forms – Part I. Learning Objectives By the end of this lecture, you should be able to: – Retrieve the values entered by a user into a form.
Functions & Objects IDIA 618 Spring 2012 Bridget M. Blodgett.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
A really fairly simple guide to: mobile browser-based application development (part 4, JQuery & DOM) Chris Greenhalgh G54UBI / Chris Greenhalgh.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
JQuery Adding behaviour…. Lecture Plan Review of last lesson Adding behaviour –click, mouseover Animation –fade, slideDown Navigation –parent, find, next.
JQUERY | INTRODUCTION. jQuery  Open source JavaScript library  Simplifies the interactions between  HTML document, or the Document Object Model (DOM),
Getting Started with Canvas IDIA Spring 2013 Bridget M. Blodgett.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Functions, Objects, and Programming IDIA 619 Spring 2014 Bridget M. Blodgett.
XML Design Goals 1.XML must be easily usable over the Internet 2.XML must support a wide variety of applications 3.XML must be compatible with SGML 4.It.
JavaScript Scripting language What is Scripting ? A scripting language, script language, or extension language is a programming language.
05 – Java Script (1) Informatics Department Parahyangan Catholic University.
JavaScript, Fourth Edition
Unleash the Power of jQuery Learning & Development Team Telerik Software Academy.
1 Javascript DOM Peter Atkinson. 2 Objectives Understand the nature and structure of the DOM Add and remove content from the page Access and change element.
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.
Modifying HTML attributes and CSS values. Learning Objectives By the end of this lecture, you should be able to: – Select based on a class (as opposed.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Java Script About Java Script Document Object Model Incorporating JavaScript Adding JavaScript to HTML Embedding a Javascript External Scripts Javascript.
Unit 13 –JQuery Basics Instructor: Brent Presley.
JavaScript is an object-based scripting language that is lightweight and cross-platform. 3-Feb-16 JavaScript.
Changing HTML Attributes each() function Anonymous Functions $(this) keyword.
Review of HTML and CSS A (very) brief review of some key fundamentals to be aware of in IT-238.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
Introduction to JQuery COGS 187A – Fall JQuery jQuery is a JavaScript library, and allows us to manipulate HTML and CSS after the page has been.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
Introduction to Javascript. What is javascript?  The most popular web scripting language in the world  Used to produce rich thin client web applications.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
CSE 154 LECTURE 9: THE DOM TREE. The DOM tree The elements of a page are nested into a tree-like structure of objects the DOM has properties and methods.
LECTURE #4: JQUERY AND FORM VALIDATION Josh Kaine Josh Kaine 4/1/2016.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Introduction to JavaScript MIS 3502, Fall 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 9/29/2016.
Introduction to.
Week 3: Introduction to Javascript
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
Introduction to JavaScript
JavaScript an introduction.
DHTML Javascript Internet Technology.
HTML A brief introduction HTML.
A second look at JavaScript
Functions BIS1523 – Lecture 17.
Introduction to JavaScript for Python Programmers
DHTML Javascript Internet Technology.
Introduction to Programming the WWW I
PHP.
T. Jumana Abu Shmais – AOU - Riyadh
Training & Development
Introduction to JavaScript
JavaScript CS 4640 Programming Languages for Web Applications
Javascript Chapter 19 and 20 5/3/2019.
CIS 136 Building Mobile Apps
Web Programming and Design
Week 5: Recap and Portfolio Site
Web Programming and Design
Web Programming and Design
Presentation transcript:

Review IDIA 619 Spring 2013 Bridget M. Blodgett

HTML A basic HTML document looks like this: Sample page Sample page This is a simple sample. HTML user agents (e.g. Web browsers) then parse this markup, turning it into a DOM (Document Object Model) tree. – A DOM tree is an in-memory representation of a document.

Updating to HTML5 The structure of pages has changed slightly: – Doctypes can now be written simply as – Charactersets are – Stylesheet links: – Scripts: Best part is these should never change and are backwards compatible

APIs Stands for Application Programming Interface – What does this really mean in terms of developing and designing things? The reinvention of HTML with HTML5 added support for a number of new features: – Local storage – 2D drawing – Offline support – Sockets and threads – Geolocation

Writing JS JS is written as a series of statements – Unlike PHP JS WILL terminate with a line break or a semi-colon You must declare a variable before using it – Use the key var before the variable name to declare it – They can be initialized at declaration but don’t need to be Variables are case sensitive

Data Types There are several basic data types – Strings are wrapped in ‘’ or “” – Numbers – Booleans can be true/false or 0/1 – Arrays

Operators JS has two categories of operators – Math +, -, *, /, ++, -- – Comparison >, =, <= === !== – Logical are a sub-category of comparison &&, ||, !

Conditional If statements – if(2 <1){alert(‘Something is Wrong’);} if…else is also accepted if (2<1){ alert(‘Something is wrong’); } else if { alert(‘Everything is fine’); } else { alert(“all clear”); } (2<1) ? alert(‘Something is wrong’) : alert (‘Everything is fine’);

Loops Very similar to other languages var i = 10; while (i >=0 ){ alert (i); i--; } For loops are similar to while loops but compress the initialize, conditional, update process onto one line

What We Know var guessInput = document.getElementById("guess"); var guess = guessInput.value; var answer = null; var answers = [ "red", "green", "blue"]; var index = Math.floor(Math.random() * answers.length); if (guess == answers[index]) { answer = "You're right! I was thinking of " + answers[index]; } else { answer = "Sorry, I was thinking of " + answers[index]; } alert(answer);

Properties Many variables have special properties that we can make use of to alter our pages – button.onclick and window.onload are two examples of these properties – What are some other built in properties for buttons in JavaScript?

Making New Elements Getting new elements to appear on the page is a two step process: modifying the DOM, adding the element to the page – document.createElement(“x”); –.innerHTML = ; We can then search for our new element’s parent and append the new element to it: –.appendChild( );

Anatomy of a Function function checkGuess(guess) { var answers = [ "red", "green", "blue"]; var index = Math.floor(Math.random() * answers.length); if (guess == answers[index]) { answer = "You're right! I was thinking of " + answers[index]; } else { answer = "Sorry, I was thinking of " + answers[index]; } return answer; }

Parameters vs Arguments When you define a function you will often give it several parameters – These are placeholder that tell the function the type of information it will accept When you call the function you may pass it several arguments – These are actual values of information that match the type described by the placeholders

Local and Global Variables Javascript will allow you to declare a new variable just about anywhere in the document But the location you choose has an effect upon what that variable can interact with If they are declared outside of any function or loop they are a global variable – Any function or code in the document can use them If they are declared inside a function they are called local variables – Only accessible to the code that is also in the function

Objects Objects are a conceptual way of thinking about coding – Their goal is to improve planning by grouping together similar properties and functions by their goals The properties of an object are simply a way of describing that object

var fido = { name: "Fido", weight: 40, breed: "Mixed", loves: ["walks", "fetching balls"] };

Using Objects You can modify or call properites of object by using the objectname.property – Like Math.random

This Keyword this is used to refer to the current object that you are manipulating or working under

function Dog(name, breed, weight) { this.name = name; this.breed = breed; this.weight = weight; this.bark = function() { if (this.weight > 25) { alert(this.name + " says Woof!"); } else { alert(this.name + " says Yip!"); } }; } var fido = new Dog("Fido", "Mixed", 38);

Using jQuery jQuery has a slightly different syntax than the JavaScript we’ve used so far jQuery is itself a function but it has a shortened form which will be what you use most often – The full function is jQuery() shortened to $() You can put CSS Selectors, HTML, and JavaScript Objects into the function

jQuery and CSS jQuery uses selectors just like CSS – Just listing the element name does all elements of that type – Preceding it with a period signifies a change to a class – Preceding it with a hash (#) signifies a change to an id CSS selectors add style to an element, jQuery selectors add behaviors to them

Process for Using jQuery The process for implementing jQuery has several steps: – Outline the project requirements – Structure the page with div tags where appropriate add CSS – Add in script section linking to the jQuery library – Put in your $(document).ready(function()) line – Add your jQuery commands nested under the ready – Comment your code so that you know what’s going on

Adding Content There are several methods that jQuery uses to add new items to the HTML page without a refresh One of the easiest to use is.append() – The information that you want to add goes inside the () – You attach the append function to the item you want to add it to – $(“.div_section”).append(“ This too! ”);

Removing Elements There is a remove function that takes an element or group of elements off the page – Once used the elements won’t even show up in the HTML view of the page The order of adding and removing elements is important – You can’t remove an element before it is added – You don’t (usually) want to remove an element you just added