Section 1

Preview this deck

Keywords

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (9)

Section 1

(9 cards)

Keywords

Front

break- Terminates a switch or a loop continue- Jumps out of a loop and starts at the top debugger- Stops the execution of JavaScript, and calls (if available) the debugging function do ... while - Executes a block of statements, and repeats the block, while a condition is true for- Marks a block of statements to be executed, as long as a condition is true function- Declares a function if ... else- Marks a block of statements to be executed, depending on a condition return- Exits a function switch- Marks a block of statements to be executed, depending on different cases try ... catch- Implements error handling to a block of statements var- Declares a variable

Back

statement

Front

var x, y, z; // Statement 1 x = 5; // Statement 2 y = 6; // Statement 3 z = x + y; // Statement 4

Back

Finding HTML Objects

Front

document.forms Returns all <form> elements document.head Returns the <head> element document.images Returns all <img> elements document.body Returns the <body> element document.documentElement Returns the <html> element document.title Returns the <title> element document.scripts Returns all <script> elements document.links Returns all <area> and <a> elements that have a href attribute

Back

output

Front

document.write() for testing (will delete page if called after page is loaded) window.alert() to display data console.log() for debugging

Back

Find HTML Element

Front

document.getElementById(id) Find an element by element id document.getElementsByTagName(name) Find elements by tag name document.getElementsByClassName(name) Find elements by class name

Back

Changing existing HTML

Front

<p id="demo"></p> <script> var cars = ["Saab", "Volvo", "BMW"]; document.getElementById("demo").innerHTML = cars; //Changes "demo" paragraph to elements of cars </script> element.innerHTML = new html content Change the inner HTML of an element element.attribute = new value Change the attribute value of an HTML element element.setAttribute(attribute, value) Change the attribute value of an HTML element element.style.property = new style Change the style of an HTML element

Back

<script> </script>

Front

tags that begin and end Javascript code within an HTML document

Back

Object

Front

var person = { firstName:"John", lastName:"Doe", age:50, eyeColor:"blue" }; objectName.propertyName or objectName["propertyName"] person.firstName or person["firstName"]

Back

Adding and Deleting HTML Elements

Front

document.createElement(element) Create an HTML element document.removeChild(element) Remove an HTML element document.appendChild(element) Add an HTML element document.replaceChild(element) Replace an HTML element document.write(text) Write into the HTML output stream

Back