SlideShare a Scribd company logo
Speaking in Code




HTML + CSS + JavaScript
How it all works



Brian Lee

Professor Liel Leibovitz
Speaking in Code


Logistics

• Today will be mostly recap

• Please feel free to ask questions at anytime
Speaking in Code


Recap: Loops

• Execute same line(s) of code over and over

• Fundamental concept in programming

• Can be trickier with JavaScript
Speaking in Code


Recap: For Loops
• Basic Syntax
   for(var i = 0; i < 10; i++) {
        console.log(i);
   }

• Initialization: define variable useful to loop
• Conditional: keep looping while this is true
   – is “i” currently less than 10?

• Increment: executed at the end of the loop
Speaking in Code


Recap: Loop Mechanics
   for(var i = 0; i < 10; i++) {
        console.log(i);
   }


1. Initialization
2. Check Conditional: Stop loop if false
3. Run Code
4. Run Increment: i++              i=i+1
5. Step 2
Speaking in Code


Recap: Infinite Loops
• Loops with no exit strategy
Speaking in Code


Recap: Arrays

• Collection of items

• Like a box (even looks like it)
   []


• Each item has a designated spot

   var doughnuts= [   ,   ,   ,     ]
Speaking in Code


Recap: Arrays – Accessing Elements

• Elements: items in arrays

• Index: location of element in array
   – Starts from 0 not 1

  var doughnuts= *‘Boston Creme’, ‘Glazed’, ‘Old Fashioned’ +

• How to access the value “Boston Creme”
Speaking in Code


Recap: Arrays – Accessing Elements

• Elements: items in arrays

• Index: location of element in array
   – Starts from 0 not 1

  var doughnuts= *‘Boston Creme’, ‘Glazed’, ‘Old Fashioned’ +
                          0           1            2
• How to access the value “Boston Creme”
  doughnuts[0]
Speaking in Code


Recap: Loops and Arrays

• Use loops to write less code
  var doughnuts = *‘Boston Creme’, ‘Glazed’, ‘Old Fashioned’ ]
  for(var i = 0; i < doughnuts.length; i++) {
       console.log(“This box has “ + doughnuts*i])
  }


  >> “This box has Boston Crème”
  >> “This box has Glazed”
  >> “This box has Old Fashioned”
Speaking in Code


Things we know about JavaScript
• Step by step instructions
   – HTML: defines content
   – CSS: defines style

• Tricky syntax (don’t forget ; or {   )
                                   }
• Variables
• if statements
• Functions
• Loops
Speaking in Code


Recap: Nesting Loops and “IF” Statements
  var temperature = 50;
  if(temperature > 60) {
       console.log(“Wow! It’s hot here!”);
  } else {
       console.log(“It should be warmer”);
  }

  var gasPrice = 1.79;
  for(var year = 2000; year <= 2013; year++){
       gasPrice = gasPrice + 1.15;
  }
  console.log(“Wow the gas price is $“ + gasPrice + “ already?!”)
Speaking in Code


Recap: Nesting Loops and “IF” Statements

for(var age = 0; age < 25; age++) {
     if(age < 21) {
          console.log("I am " + age + " years old and sad");
     } else {
          console.log("I am " + age + " years old and suddenly happy");
     }
 }
Speaking in Code


Reminder: So Why JavaScript?
• Gives instructions to the web page
   – Notice you can write JavaScript in the browser console?

• Real world application
   – Facebook: create your own “buttons” through code

• So many uses
   – Add/remove content dynamically
   – Change styles
   – React to user interaction
Speaking in Code


Reminder: Adding JavaScript

• Add JS to a page with the <script> tag

 <script type="text/javascript" src="script.js"></script>

• Just another file
   – .js
Speaking in Code


Reminder: Adding JavaScript

• Trigger functions based on user interaction
   – Clicking buttons -> runs a sequence of code ie.) functions

• Using the onclick handler

 <p onclick="someFunction()">Click me, I'm a paragraph</p>

• someFunction is defined in somewhere in the .js file
Speaking in Code


Reminder: JavaScript Commands

• So what else can we do with JS?
 document.getElementById('my-paragraph').innerHTML = ’Nerd Alert!';

• Find the element with the id          my-paragraph   and set the
  HTML within it to “Nerd Alert!”

• Scroll right 0px and down 100px

 window.scrollBy(0, 100);
Speaking in Code


If Statements on the Web

• Checking if a username is long enough
 var username = document.getElementById('username').value;
 if(username.length > 5) {
      alert('Registered!');
 } else {
      alert('Please supply a username longer than 5 characters.');
 }
Speaking in Code


For Loops on the Web

• Facebook select all

  var elms = document.getElementsByName("checkableitems[]");
  for(i = 0; i < elms.length; i++) {
       if (elms[i].type === "checkbox”) ,
             elms[i].click();
       }
  }
Speaking in Code


Put Your Knowledge to the Test!

http://bit.ly/jshtmlcss
Speaking in Code


Next Week!

• Your choice:
   – jQuery, Python, or Ruby!

• jQuery – JavaScript library that gives you ability to
  manipulate web pages MUCH easier

• Python/Ruby – “Backend” languages
   – So, what does code on the server side look like?

More Related Content

Similar to Week 7 html css js

Week 6 java script loops
Week 6   java script loopsWeek 6   java script loops
Week 6 java script loops
brianjihoonlee
 
Week 5 java script functions
Week 5  java script functionsWeek 5  java script functions
Week 5 java script functions
brianjihoonlee
 
Lecture 03 - JQuery.pdf
Lecture 03 - JQuery.pdfLecture 03 - JQuery.pdf
Lecture 03 - JQuery.pdf
Lê Thưởng
 
Chapter i c#(console application and programming)
Chapter i c#(console application and programming)Chapter i c#(console application and programming)
Chapter i c#(console application and programming)
Chhom Karath
 
Intro to JavaScript - Thinkful LA, June 2017
Intro to JavaScript - Thinkful LA, June 2017Intro to JavaScript - Thinkful LA, June 2017
Intro to JavaScript - Thinkful LA, June 2017
Thinkful
 
Thinkful - Intro to JavaScript
Thinkful - Intro to JavaScriptThinkful - Intro to JavaScript
Thinkful - Intro to JavaScript
TJ Stalcup
 
Intro to javascript (6:19)
Intro to javascript (6:19)Intro to javascript (6:19)
Intro to javascript (6:19)
Thinkful
 
Intro to javascript (6:27)
Intro to javascript (6:27)Intro to javascript (6:27)
Intro to javascript (6:27)
David Coulter
 
PHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginnersPHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginners
Mohammed Mushtaq Ahmed
 
Leveling Up at JavaScript
Leveling Up at JavaScriptLeveling Up at JavaScript
Leveling Up at JavaScript
Raymond Camden
 
Week 8 intro to python
Week 8   intro to pythonWeek 8   intro to python
Week 8 intro to python
brianjihoonlee
 
Writing clean code
Writing clean codeWriting clean code
Writing clean code
Angel Garcia Olloqui
 
Perfect Code
Perfect CodePerfect Code
Perfect Code
Artem Tabalin
 
Lift talk
Lift talkLift talk
Lift talk
Winston Chen
 
JavaScript Good Practices
JavaScript Good PracticesJavaScript Good Practices
JavaScript Good Practices
Jussi Pohjolainen
 
Javascript done right - Open Web Camp III
Javascript done right - Open Web Camp IIIJavascript done right - Open Web Camp III
Javascript done right - Open Web Camp III
Dirk Ginader
 
Testing web APIs
Testing web APIsTesting web APIs
Testing web APIs
FDConf
 
Selenium Tips & Tricks - StarWest 2015
Selenium Tips & Tricks - StarWest 2015Selenium Tips & Tricks - StarWest 2015
Selenium Tips & Tricks - StarWest 2015
Andrew Krug
 
Performance patterns
Performance patternsPerformance patterns
Performance patterns
Stoyan Stefanov
 
Tech talk on code quality
Tech talk on code qualityTech talk on code quality
Tech talk on code quality
Alexander Osin
 

Similar to Week 7 html css js (20)

Week 6 java script loops
Week 6   java script loopsWeek 6   java script loops
Week 6 java script loops
 
Week 5 java script functions
Week 5  java script functionsWeek 5  java script functions
Week 5 java script functions
 
Lecture 03 - JQuery.pdf
Lecture 03 - JQuery.pdfLecture 03 - JQuery.pdf
Lecture 03 - JQuery.pdf
 
Chapter i c#(console application and programming)
Chapter i c#(console application and programming)Chapter i c#(console application and programming)
Chapter i c#(console application and programming)
 
Intro to JavaScript - Thinkful LA, June 2017
Intro to JavaScript - Thinkful LA, June 2017Intro to JavaScript - Thinkful LA, June 2017
Intro to JavaScript - Thinkful LA, June 2017
 
Thinkful - Intro to JavaScript
Thinkful - Intro to JavaScriptThinkful - Intro to JavaScript
Thinkful - Intro to JavaScript
 
Intro to javascript (6:19)
Intro to javascript (6:19)Intro to javascript (6:19)
Intro to javascript (6:19)
 
Intro to javascript (6:27)
Intro to javascript (6:27)Intro to javascript (6:27)
Intro to javascript (6:27)
 
PHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginnersPHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginners
 
Leveling Up at JavaScript
Leveling Up at JavaScriptLeveling Up at JavaScript
Leveling Up at JavaScript
 
Week 8 intro to python
Week 8   intro to pythonWeek 8   intro to python
Week 8 intro to python
 
Writing clean code
Writing clean codeWriting clean code
Writing clean code
 
Perfect Code
Perfect CodePerfect Code
Perfect Code
 
Lift talk
Lift talkLift talk
Lift talk
 
JavaScript Good Practices
JavaScript Good PracticesJavaScript Good Practices
JavaScript Good Practices
 
Javascript done right - Open Web Camp III
Javascript done right - Open Web Camp IIIJavascript done right - Open Web Camp III
Javascript done right - Open Web Camp III
 
Testing web APIs
Testing web APIsTesting web APIs
Testing web APIs
 
Selenium Tips & Tricks - StarWest 2015
Selenium Tips & Tricks - StarWest 2015Selenium Tips & Tricks - StarWest 2015
Selenium Tips & Tricks - StarWest 2015
 
Performance patterns
Performance patternsPerformance patterns
Performance patterns
 
Tech talk on code quality
Tech talk on code qualityTech talk on code quality
Tech talk on code quality
 

Recently uploaded

How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
SitimaJohn
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
Webinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data WarehouseWebinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data Warehouse
Federico Razzoli
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Project Management Semester Long Project - Acuity
Project Management Semester Long Project - AcuityProject Management Semester Long Project - Acuity
Project Management Semester Long Project - Acuity
jpupo2018
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 

Recently uploaded (20)

How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
Webinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data WarehouseWebinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data Warehouse
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Project Management Semester Long Project - Acuity
Project Management Semester Long Project - AcuityProject Management Semester Long Project - Acuity
Project Management Semester Long Project - Acuity
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 

Week 7 html css js

  • 1. Speaking in Code HTML + CSS + JavaScript How it all works Brian Lee Professor Liel Leibovitz
  • 2. Speaking in Code Logistics • Today will be mostly recap • Please feel free to ask questions at anytime
  • 3. Speaking in Code Recap: Loops • Execute same line(s) of code over and over • Fundamental concept in programming • Can be trickier with JavaScript
  • 4. Speaking in Code Recap: For Loops • Basic Syntax for(var i = 0; i < 10; i++) { console.log(i); } • Initialization: define variable useful to loop • Conditional: keep looping while this is true – is “i” currently less than 10? • Increment: executed at the end of the loop
  • 5. Speaking in Code Recap: Loop Mechanics for(var i = 0; i < 10; i++) { console.log(i); } 1. Initialization 2. Check Conditional: Stop loop if false 3. Run Code 4. Run Increment: i++ i=i+1 5. Step 2
  • 6. Speaking in Code Recap: Infinite Loops • Loops with no exit strategy
  • 7. Speaking in Code Recap: Arrays • Collection of items • Like a box (even looks like it) [] • Each item has a designated spot var doughnuts= [ , , , ]
  • 8. Speaking in Code Recap: Arrays – Accessing Elements • Elements: items in arrays • Index: location of element in array – Starts from 0 not 1 var doughnuts= *‘Boston Creme’, ‘Glazed’, ‘Old Fashioned’ + • How to access the value “Boston Creme”
  • 9. Speaking in Code Recap: Arrays – Accessing Elements • Elements: items in arrays • Index: location of element in array – Starts from 0 not 1 var doughnuts= *‘Boston Creme’, ‘Glazed’, ‘Old Fashioned’ + 0 1 2 • How to access the value “Boston Creme” doughnuts[0]
  • 10. Speaking in Code Recap: Loops and Arrays • Use loops to write less code var doughnuts = *‘Boston Creme’, ‘Glazed’, ‘Old Fashioned’ ] for(var i = 0; i < doughnuts.length; i++) { console.log(“This box has “ + doughnuts*i]) } >> “This box has Boston Crème” >> “This box has Glazed” >> “This box has Old Fashioned”
  • 11. Speaking in Code Things we know about JavaScript • Step by step instructions – HTML: defines content – CSS: defines style • Tricky syntax (don’t forget ; or { ) } • Variables • if statements • Functions • Loops
  • 12. Speaking in Code Recap: Nesting Loops and “IF” Statements var temperature = 50; if(temperature > 60) { console.log(“Wow! It’s hot here!”); } else { console.log(“It should be warmer”); } var gasPrice = 1.79; for(var year = 2000; year <= 2013; year++){ gasPrice = gasPrice + 1.15; } console.log(“Wow the gas price is $“ + gasPrice + “ already?!”)
  • 13. Speaking in Code Recap: Nesting Loops and “IF” Statements for(var age = 0; age < 25; age++) { if(age < 21) { console.log("I am " + age + " years old and sad"); } else { console.log("I am " + age + " years old and suddenly happy"); } }
  • 14. Speaking in Code Reminder: So Why JavaScript? • Gives instructions to the web page – Notice you can write JavaScript in the browser console? • Real world application – Facebook: create your own “buttons” through code • So many uses – Add/remove content dynamically – Change styles – React to user interaction
  • 15. Speaking in Code Reminder: Adding JavaScript • Add JS to a page with the <script> tag <script type="text/javascript" src="script.js"></script> • Just another file – .js
  • 16. Speaking in Code Reminder: Adding JavaScript • Trigger functions based on user interaction – Clicking buttons -> runs a sequence of code ie.) functions • Using the onclick handler <p onclick="someFunction()">Click me, I'm a paragraph</p> • someFunction is defined in somewhere in the .js file
  • 17. Speaking in Code Reminder: JavaScript Commands • So what else can we do with JS? document.getElementById('my-paragraph').innerHTML = ’Nerd Alert!'; • Find the element with the id my-paragraph and set the HTML within it to “Nerd Alert!” • Scroll right 0px and down 100px window.scrollBy(0, 100);
  • 18. Speaking in Code If Statements on the Web • Checking if a username is long enough var username = document.getElementById('username').value; if(username.length > 5) { alert('Registered!'); } else { alert('Please supply a username longer than 5 characters.'); }
  • 19. Speaking in Code For Loops on the Web • Facebook select all var elms = document.getElementsByName("checkableitems[]"); for(i = 0; i < elms.length; i++) { if (elms[i].type === "checkbox”) , elms[i].click(); } }
  • 20. Speaking in Code Put Your Knowledge to the Test! http://bit.ly/jshtmlcss
  • 21. Speaking in Code Next Week! • Your choice: – jQuery, Python, or Ruby! • jQuery – JavaScript library that gives you ability to manipulate web pages MUCH easier • Python/Ruby – “Backend” languages – So, what does code on the server side look like?

Editor's Notes

  1. Like microwave example - button
  2. var username = document.getElementById(&apos;username&apos;).value; if(username.length &gt; 5) { alert(&apos;Registered!&apos;); } else { alert(&apos;Please supply a username longer than 5 characters.&apos;); }