SlideShare a Scribd company logo
Introduction to JavaScript
  Learn how to program your computer!
0
  You can and must
understand computers
        NOW
“ Everything is deeply intertwingled. In an
  important sense there are no “subjects” at all;
 there is only all knowledge, since the cross-
 connections among the myriad topics of this
 world simply cannot be divided up neatly.”

 —Ted Nelson, Computer Lib/Dream Machines
“ When human beings acquired language, we
learned not just how to listen but how to speak.
When we gained literacy, we learned not just how
to read but how to write. And as we move into an
increasingly digital reality, we must learn not just
how to use programs but how to make them.”

—Douglas Rushkoff, Program or Be Programmed
“ The single most significant change in the politics
  of cyberspace is the coming of age of this simple
 idea: The code is law. The architectures of
 cyberspace are as important as the law in defining
 and defeating the liberties of the Net.”

 —Lawrence Lessig, The Code Is the Law
1
Learning a new language
Code is text
Programming is
    typing
Programming is very
   careful typing
Programming is
  fast typing
Programming is
figuring out why it
       broke
Programming in general

• A series of text files that get compiled
  and executed

• Code is “digested,” going from human-
  readable to a hardware-ready form

• Ultimately programs run as assembly,
  low-level instructions for your CPU
JavaScript in particular

• Increasingly the web page scripting
  language

• Most likely the widest deployed
  runtime

• JavaScript has nothing to do with
  Java, except some syntax similarities
Lines of code


• A line of code is a basic unit of
  programming

• Tells the computer to do something
• Sometimes a “line” of code can span
  more than one line
A simple line of code

alert("Hello, world!");
Let’s try this using
      Firebug
2
Writing code
Compilers are unforgiving

• The computer cuts you no slack
• All code is subject to bugs
• The error console is your friend
• Debugging is about identifying,
  characterizing, and resolving
  problems
Intro to JavaScript
Intro to JavaScript
Intro to JavaScript
A simple line of code

    alert("Hello, world!");

Function name
A simple line of code

     alert("Hello, world!");

Function name Parentheses call the function
A simple line of code

     alert("Hello, world!");

Function name Parentheses call the function

                        Function argument (a string)
A simple line of code

     alert("Hello, world!");

Function name Parentheses call the function

                        Function argument (a string)

                                    Designates the end of the line
3
Variables
The variable metaphor



     “Variables are like a box
      you can put data into.”
The variable metaphor
The variable metaphor
Variables


• Variables store data for future use
• var x = y; is how you assign a new
  variable in JavaScript

• We can now refer to x in future lines
  of code, and know it means y
Variables (boolean type)


• Variables store data for future use
• var x = true; is how you assign a new
  variable in JavaScript

• We can now refer to x in future lines
  of code, and know it means true
Variables (boolean type)


• Variables store data for future use
• var x = false; is how you assign a new
  variable in JavaScript

• We can now refer to x in future lines
  of code, and know it means false
Variables (numeric type)


• Variables store data for future use
• var x = 47; is how you assign a new
  variable in JavaScript

• We can now refer to x in future lines
  of code, and know it means 47
Variables (string type)


• Variables store data for future use
• var x = "pony"; is how you assign a
  new variable in JavaScript

• We can now refer to x in future lines
  of code, and know it means pony.
Variable logic


// What   is the value of z?
var x =   3;
var y =   x + 1;
var z =   y;
4
Functions
Multiple lines of code



var msg = "Hello, world!";
var func = alert;
func(msg);

                    Designate the ends of the lines
Multiple lines of code



var msg = "Hello, world!";
var func = alert;
func(msg);



The first line stores a string
Multiple lines of code



var msg = "Hello, world!";
var func = alert;
func(msg);



The second line stores a function
Multiple lines of code



var msg = "Hello, world!";
var func = alert;
func(msg);



The third line executes the
stored function with the string
Commenting code

// First we store the message
var msg = "Hello, world!";

// Next, we choose a function to call
var func = alert;

// Finally, we combine the two
func(msg);
Commenting code

/*

This code demonstrates the standard
Hello World program, over three lines
instead of just one.

*/
var msg = "Hello, world!";
var func = alert;
func(msg);
Creating a new function

// Outputs a simple message
function output_message() {
  var msg = "Hello, world!";
  var func = alert;
  func(msg);
}
Calling our function

// Outputs a simple message
function output_message() {
  var msg = "Hello, world!";
  var func = alert;
  func(msg);
}

output_message();
Arguments

// Outputs a simple message
function output_message(msg) {
  var func = alert;
  func(msg);
}

output_message("Hello, world!");
output_message("¡Hola, mundo!");
5
Libraries
JavaScript on the web


<script>

// JavaScript code is typically embedded in HTML
// <script> tags

</script>
HTML + JavaScript
<html>
  <head>
    <title>HTML + JavaScript</title>
  </head>
  <body>
    <p>Stuff *on* the page goes up here.</p>
    <script>

    // JavaScript code that modifies the page should
    // go below everything else in the <body>.

    </script>
  </body>
</html>
Hide content
<html>
  <head>
    <title>Hide content</title>
  </head>
  <body>
    <p id="hide">Click to hide me!</p>
    <script src="mootools.js"></script>
    <script>
    $('hide').addEvent('click', function() {
       $('hide').fade('out');
    });
    </script>
  </body>
</html>
HTML + CSS + JavaScript
<html>
  <head>
    <title>HTML + CSS + JavaScript</title>
    <style>
    #content {
       background: #000;
    }
    </style>
  </head>
  <body>
    <p id="content">Hello, world!</p>
    <script>
      var content = document.getElementById('content');
       content.style.color = '#fff';
    </script>
  </body>
</html>
HTML + CSS + JavaScript

<html>
  <head>
    <title>HTML + CSS + JavaScript</title>
    <link rel="stylesheet" href="styles.css" />
  </head>
  <body>
    <p>
       Separating code into .js and .css files is a
       good way to keep things tidy.
    </p>
    <script src="scripts.js"></script>
  </body>
</html>
6
Slide show
Intro to JavaScript
Slide show HTML
<html>
  <head>
    <title>Slide show</title>
    <link rel="stylesheet" href="styles.css" />
  </head>
  <body>
    <div id="slides">
       <div id="inner">
         <img src="images/1.jpg" />
         <img src="images/2.jpg" />
         <img src="images/3.jpg" />
         <img src="images/4.jpg" />
       </div>
    </div>
    <script src="mootools.js"></script>
    <script src="script.js"></script>
  </body>
</html>
Slide show CSS
#slides {
  width: 991px;
  height: 671px;
  margin: 0 auto;
  overflow: hidden;
  position: relative;
}

#inner {
  position: absolute;
  left: 0;
  top: 0;
}

#slides img {
  float: left;
}
Slide show JavaScript


var width = 991;
var n = 0;
var count = $$('#slides img').length;

$('slides').addEvent('click', function() {
  n = (n + 1) % count; // Increment
  $('inner').tween('left', n * -width);
});
7
What next?
Come up with a
   project
Try to build it
   yourself
Take your time, it
won’t come quickly
Resources
•   Eloquent JavaScript   •   _why’s poignant
                              guide to Ruby
•   MooTorial
                          •   Dive into Python
•   w3schools.com
                          •   Visual Quickstart
•   Mozilla devmo             Guide

•   WebMonkey             •   Lynda tutorials

•   The Rhino Book
http://www.vimeo.com/5047563
http://www.vimeo.com/5047563

More Related Content

What's hot (20)

PPTX
Lecture 5: Client Side Programming 1
Artificial Intelligence Institute at UofSC
 
PPTX
JavaScript Fundamentals & JQuery
Jamshid Hashimi
 
PPTX
Ruby Programming Language - Introduction
Kwangshin Oh
 
PPTX
Ruby On Rails Intro
Sarah Allen
 
ODP
Ruby
Aizat Faiz
 
PPTX
Javascript Basics by Bonny
Bonny Chacko
 
PPT
JavaScript & Dom Manipulation
Mohammed Arif
 
PPTX
All of Javascript
Togakangaroo
 
PDF
Unit 4(it workshop)
Dr.Lokesh Gagnani
 
PPT
Ruby For Java Programmers
Mike Bowler
 
PPT
JavaScript Basics with baby steps
Muhammad khurram khan
 
PPTX
Welcome to hack
Timothy Chandler
 
ODP
Regular Expressions: Backtracking, and The Little Engine that Could(n't)?
daoswald
 
PDF
Introducing ruby on rails
Priceen
 
PPTX
Why Ruby?
IT Weekend
 
PDF
Php converted pdf
Northpole Web Service
 
PPTX
JavaScript and jQuery Basics
Kaloyan Kosev
 
PPT
Javascript 2009
borkweb
 
PPT
JavaScript
Doncho Minkov
 
Lecture 5: Client Side Programming 1
Artificial Intelligence Institute at UofSC
 
JavaScript Fundamentals & JQuery
Jamshid Hashimi
 
Ruby Programming Language - Introduction
Kwangshin Oh
 
Ruby On Rails Intro
Sarah Allen
 
Javascript Basics by Bonny
Bonny Chacko
 
JavaScript & Dom Manipulation
Mohammed Arif
 
All of Javascript
Togakangaroo
 
Unit 4(it workshop)
Dr.Lokesh Gagnani
 
Ruby For Java Programmers
Mike Bowler
 
JavaScript Basics with baby steps
Muhammad khurram khan
 
Welcome to hack
Timothy Chandler
 
Regular Expressions: Backtracking, and The Little Engine that Could(n't)?
daoswald
 
Introducing ruby on rails
Priceen
 
Why Ruby?
IT Weekend
 
Php converted pdf
Northpole Web Service
 
JavaScript and jQuery Basics
Kaloyan Kosev
 
Javascript 2009
borkweb
 
JavaScript
Doncho Minkov
 

Viewers also liked (20)

KEY
Intro to Javascript
Kevin Ball
 
PPTX
JavaScript - Intro
Anton Tibblin
 
PDF
Intro to JavaScript
Yakov Fain
 
PPT
Introduction to Javascript
Amit Tyagi
 
PDF
Intro to JavaScript
Jussi Pohjolainen
 
PDF
NodeJs Intro - JavaScript Zagreb Meetup #1
Tomislav Capan
 
PPTX
Intro to Javascript
Anjan Banda
 
PDF
Intro to javascript (4 week)
Jamal Sinclair O'Garro
 
PDF
Intro to JavaScript
Alessandro Muraro
 
PPT
Java Script Introduction
jason hu 金良胡
 
KEY
Introduction to javascript
Syd Lawrence
 
PDF
Javascript intro for MAH
Aleksander Fabijan
 
PDF
JavaScript Intro
Eric Brown
 
PDF
Web Design
Speedy Little Website
 
PPT
Javascript Intro 01
vikram singh
 
PDF
Introduction to web development
Alberto Apellidos
 
PDF
Intro to Javascript and jQuery
Shawn Calvert
 
PDF
Basics of JavaScript
Bala Narayanan
 
PDF
Intro to HTML
Randy Oest II
 
PDF
Front end development best practices
Karolina Coates
 
Intro to Javascript
Kevin Ball
 
JavaScript - Intro
Anton Tibblin
 
Intro to JavaScript
Yakov Fain
 
Introduction to Javascript
Amit Tyagi
 
Intro to JavaScript
Jussi Pohjolainen
 
NodeJs Intro - JavaScript Zagreb Meetup #1
Tomislav Capan
 
Intro to Javascript
Anjan Banda
 
Intro to javascript (4 week)
Jamal Sinclair O'Garro
 
Intro to JavaScript
Alessandro Muraro
 
Java Script Introduction
jason hu 金良胡
 
Introduction to javascript
Syd Lawrence
 
Javascript intro for MAH
Aleksander Fabijan
 
JavaScript Intro
Eric Brown
 
Javascript Intro 01
vikram singh
 
Introduction to web development
Alberto Apellidos
 
Intro to Javascript and jQuery
Shawn Calvert
 
Basics of JavaScript
Bala Narayanan
 
Intro to HTML
Randy Oest II
 
Front end development best practices
Karolina Coates
 
Ad

Similar to Intro to JavaScript (20)

PPT
Introduction to JavaScript
Andres Baravalle
 
PPTX
JavaScript New Tutorial Class XI and XII.pptx
rish15r890
 
PPTX
JavaScript_III.pptx
rashmiisrani1
 
PPTX
Lecture-15.pptx
vishal choudhary
 
PDF
javascriptPresentation.pdf
wildcat9335
 
PPTX
Lecture 5 javascript
Mujtaba Haider
 
PPT
Java Script Programming on Web Application
SripathiRavi1
 
PPTX
Web programming
Leo Mark Villar
 
PPTX
gdscWorkShopJavascriptintroductions.pptx
sandeshshahapur
 
PPTX
Chapter 3 INTRODUCTION TO JAVASCRIPT S.pptx
KelemAlebachew
 
PPTX
Java script
Sukrit Gupta
 
PPT
17javascript.ppt17javascript.ppt17javascript.ppt
hodit46
 
PPTX
Unit5_Web_Updvvgxsvjbffcvvgbjifszated.pptx
1si23bt001
 
PPTX
04-JS.pptx
RazanMazen4
 
PPTX
04-JS.pptx
RazanMazen4
 
PPTX
04-JS.pptx
RazanMazen4
 
PDF
CS8651- Unit 2 - JS.internet programming paper anna university -2017 regulation
amrashbhanuabdul
 
PPTX
Java script basics
Shrivardhan Limbkar
 
PDF
Training javascript 2012 hcmut
University of Technology
 
Introduction to JavaScript
Andres Baravalle
 
JavaScript New Tutorial Class XI and XII.pptx
rish15r890
 
JavaScript_III.pptx
rashmiisrani1
 
Lecture-15.pptx
vishal choudhary
 
javascriptPresentation.pdf
wildcat9335
 
Lecture 5 javascript
Mujtaba Haider
 
Java Script Programming on Web Application
SripathiRavi1
 
Web programming
Leo Mark Villar
 
gdscWorkShopJavascriptintroductions.pptx
sandeshshahapur
 
Chapter 3 INTRODUCTION TO JAVASCRIPT S.pptx
KelemAlebachew
 
Java script
Sukrit Gupta
 
17javascript.ppt17javascript.ppt17javascript.ppt
hodit46
 
Unit5_Web_Updvvgxsvjbffcvvgbjifszated.pptx
1si23bt001
 
04-JS.pptx
RazanMazen4
 
04-JS.pptx
RazanMazen4
 
04-JS.pptx
RazanMazen4
 
CS8651- Unit 2 - JS.internet programming paper anna university -2017 regulation
amrashbhanuabdul
 
Java script basics
Shrivardhan Limbkar
 
Training javascript 2012 hcmut
University of Technology
 
Ad

More from Dan Phiffer (7)

PDF
Occupy.here
Dan Phiffer
 
PDF
Static layouts with css
Dan Phiffer
 
PDF
Word press templates
Dan Phiffer
 
PDF
Intro to word press
Dan Phiffer
 
PDF
Diving into php
Dan Phiffer
 
PDF
The web context
Dan Phiffer
 
PDF
Web tech 101
Dan Phiffer
 
Occupy.here
Dan Phiffer
 
Static layouts with css
Dan Phiffer
 
Word press templates
Dan Phiffer
 
Intro to word press
Dan Phiffer
 
Diving into php
Dan Phiffer
 
The web context
Dan Phiffer
 
Web tech 101
Dan Phiffer
 

Recently uploaded (20)

PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PPTX
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
PDF
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PDF
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
PDF
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
Dimensions of Societal Planning in Commonism
StefanMz
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 

Intro to JavaScript

  • 1. Introduction to JavaScript Learn how to program your computer!
  • 2. 0 You can and must understand computers NOW
  • 3. “ Everything is deeply intertwingled. In an important sense there are no “subjects” at all; there is only all knowledge, since the cross- connections among the myriad topics of this world simply cannot be divided up neatly.” —Ted Nelson, Computer Lib/Dream Machines
  • 4. “ When human beings acquired language, we learned not just how to listen but how to speak. When we gained literacy, we learned not just how to read but how to write. And as we move into an increasingly digital reality, we must learn not just how to use programs but how to make them.” —Douglas Rushkoff, Program or Be Programmed
  • 5. “ The single most significant change in the politics of cyberspace is the coming of age of this simple idea: The code is law. The architectures of cyberspace are as important as the law in defining and defeating the liberties of the Net.” —Lawrence Lessig, The Code Is the Law
  • 6. 1 Learning a new language
  • 8. Programming is typing
  • 9. Programming is very careful typing
  • 10. Programming is fast typing
  • 12. Programming in general • A series of text files that get compiled and executed • Code is “digested,” going from human- readable to a hardware-ready form • Ultimately programs run as assembly, low-level instructions for your CPU
  • 13. JavaScript in particular • Increasingly the web page scripting language • Most likely the widest deployed runtime • JavaScript has nothing to do with Java, except some syntax similarities
  • 14. Lines of code • A line of code is a basic unit of programming • Tells the computer to do something • Sometimes a “line” of code can span more than one line
  • 15. A simple line of code alert("Hello, world!");
  • 16. Let’s try this using Firebug
  • 18. Compilers are unforgiving • The computer cuts you no slack • All code is subject to bugs • The error console is your friend • Debugging is about identifying, characterizing, and resolving problems
  • 22. A simple line of code alert("Hello, world!"); Function name
  • 23. A simple line of code alert("Hello, world!"); Function name Parentheses call the function
  • 24. A simple line of code alert("Hello, world!"); Function name Parentheses call the function Function argument (a string)
  • 25. A simple line of code alert("Hello, world!"); Function name Parentheses call the function Function argument (a string) Designates the end of the line
  • 27. The variable metaphor “Variables are like a box you can put data into.”
  • 30. Variables • Variables store data for future use • var x = y; is how you assign a new variable in JavaScript • We can now refer to x in future lines of code, and know it means y
  • 31. Variables (boolean type) • Variables store data for future use • var x = true; is how you assign a new variable in JavaScript • We can now refer to x in future lines of code, and know it means true
  • 32. Variables (boolean type) • Variables store data for future use • var x = false; is how you assign a new variable in JavaScript • We can now refer to x in future lines of code, and know it means false
  • 33. Variables (numeric type) • Variables store data for future use • var x = 47; is how you assign a new variable in JavaScript • We can now refer to x in future lines of code, and know it means 47
  • 34. Variables (string type) • Variables store data for future use • var x = "pony"; is how you assign a new variable in JavaScript • We can now refer to x in future lines of code, and know it means pony.
  • 35. Variable logic // What is the value of z? var x = 3; var y = x + 1; var z = y;
  • 37. Multiple lines of code var msg = "Hello, world!"; var func = alert; func(msg); Designate the ends of the lines
  • 38. Multiple lines of code var msg = "Hello, world!"; var func = alert; func(msg); The first line stores a string
  • 39. Multiple lines of code var msg = "Hello, world!"; var func = alert; func(msg); The second line stores a function
  • 40. Multiple lines of code var msg = "Hello, world!"; var func = alert; func(msg); The third line executes the stored function with the string
  • 41. Commenting code // First we store the message var msg = "Hello, world!"; // Next, we choose a function to call var func = alert; // Finally, we combine the two func(msg);
  • 42. Commenting code /* This code demonstrates the standard Hello World program, over three lines instead of just one. */ var msg = "Hello, world!"; var func = alert; func(msg);
  • 43. Creating a new function // Outputs a simple message function output_message() { var msg = "Hello, world!"; var func = alert; func(msg); }
  • 44. Calling our function // Outputs a simple message function output_message() { var msg = "Hello, world!"; var func = alert; func(msg); } output_message();
  • 45. Arguments // Outputs a simple message function output_message(msg) { var func = alert; func(msg); } output_message("Hello, world!"); output_message("¡Hola, mundo!");
  • 47. JavaScript on the web <script> // JavaScript code is typically embedded in HTML // <script> tags </script>
  • 48. HTML + JavaScript <html> <head> <title>HTML + JavaScript</title> </head> <body> <p>Stuff *on* the page goes up here.</p> <script> // JavaScript code that modifies the page should // go below everything else in the <body>. </script> </body> </html>
  • 49. Hide content <html> <head> <title>Hide content</title> </head> <body> <p id="hide">Click to hide me!</p> <script src="mootools.js"></script> <script> $('hide').addEvent('click', function() { $('hide').fade('out'); }); </script> </body> </html>
  • 50. HTML + CSS + JavaScript <html> <head> <title>HTML + CSS + JavaScript</title> <style> #content { background: #000; } </style> </head> <body> <p id="content">Hello, world!</p> <script> var content = document.getElementById('content'); content.style.color = '#fff'; </script> </body> </html>
  • 51. HTML + CSS + JavaScript <html> <head> <title>HTML + CSS + JavaScript</title> <link rel="stylesheet" href="styles.css" /> </head> <body> <p> Separating code into .js and .css files is a good way to keep things tidy. </p> <script src="scripts.js"></script> </body> </html>
  • 54. Slide show HTML <html> <head> <title>Slide show</title> <link rel="stylesheet" href="styles.css" /> </head> <body> <div id="slides"> <div id="inner"> <img src="images/1.jpg" /> <img src="images/2.jpg" /> <img src="images/3.jpg" /> <img src="images/4.jpg" /> </div> </div> <script src="mootools.js"></script> <script src="script.js"></script> </body> </html>
  • 55. Slide show CSS #slides { width: 991px; height: 671px; margin: 0 auto; overflow: hidden; position: relative; } #inner { position: absolute; left: 0; top: 0; } #slides img { float: left; }
  • 56. Slide show JavaScript var width = 991; var n = 0; var count = $$('#slides img').length; $('slides').addEvent('click', function() { n = (n + 1) % count; // Increment $('inner').tween('left', n * -width); });
  • 58. Come up with a project
  • 59. Try to build it yourself
  • 60. Take your time, it won’t come quickly
  • 61. Resources • Eloquent JavaScript • _why’s poignant guide to Ruby • MooTorial • Dive into Python • w3schools.com • Visual Quickstart • Mozilla devmo Guide • WebMonkey • Lynda tutorials • The Rhino Book