• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/31

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

31 Cards in this Set

  • Front
  • Back
why might a simple javascript command to change the contents of an element not work if it is placed above the element?
the script element gets evaluated before the element it's acting on is processed
what happens if you reference an html element that doesn't exist in an external javascript file?
the javascript won't run
how do you declare a variable? Many in a single statement?
var var_name;
var var_1, var_2, var_3;
how do you get information about the browser?
via the navigator object
e.g.
navigator.userAgent() returns the user-agent header which tells what browser/device is being used
how do you create an object using the object literal approach
var instance_name =
{member_1:value,
member_n:value,
method: function(){[function_body]}
} ;

methods are just members whose value is an anonymous functions
what is json?
a data format that has the following form

{name:value,...}
where value can possibly be an array of form
[element, ...]
and element may be a json object
what does array_instance.pop() do?
it's a mutable function that returns and removes the last element of an array
how do you get the attributes of a javascript object?
[object name].toSource()
what is the role of javascript in user interface construction?
controlling behavior
how do you create a javascript array and assign it to a variable?
var varname = [value1, value2, ...];
how do you create a function and name it?
var functionName = function (arg1, arg2, ...) {
body
};
how is a conditional written in javascript?
if ( condition){
thing to do
}
else{
other thing to do
}
how does javascript interact with an html page?
through the DOM
what is the DOM?
a tree of objects that mirrors the nested structure of elements in a web page
how do you access an html element by its id in javascript?
document.getElementById('elementid');
how do you get an array of html elements by their tag name in javascript?
document.getElementsByTagName('tag');
how would you do something like the css selector #about p{} in order to get all the p elements in the #about element?
document.getElementsById('about').getElementsByTagName('p');
how do you get a reference to a node for an element that is the parent of a given element?
givenElement.parentNode
what properties are useful for walking down the DOM tree?
.childNodes, .firstChild, .lastChild
how do you access elements horizontally in the DOM tree?
.nextSibling, .previousSibling
what is an event in javascript?
things that occur when actions happen on a page
what are the most common events?
click, mouseover, mouseout, mousedown, mouseup, blur, focus, load
what is the blur event?
when a form element is not in focus anymore
how do you use events in javascript and the DOM?
attach a listener functions for an event to an element/node
how do you add a listener function to an element?
element.addEventListener('event_name', 'do_something_function', false);
how do you check for whether you should use a browser specific function?
if(elementReference.questionableFunction){
elementReference.questionableFunction();
}
how do you change the style of an element in javascript?
elementReference.style.property = 'newValue';
what is the syntax format for dash-separated CSS names in javascript?
camelCase
what does the this keyword do in javascript?
it is a reference to the object that owns the function from which this is called
what is a good way to separate behavior and presentation instead of using javascript to change element styles directly?
use javascript to change the class names usually through a javascript library function for adding or removing class names
how do you use javascript to prevent the default behavior of an element?
attach a listener function to the element and have it call
this.preventDefault();