java 3 Flashcards

(33 cards)

1
Q

document object model

A

gives you scripting access to all elements on a web page

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

DOM defines:

A
  • HTML5 elements as objects
  • properties of all HTML elements
  • methods to access all HTML elements
  • events for all HTML elements
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what can Java do (simple)

A

create, modify, and remove elements in the page dynamically

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

list of what java can do

A
  • change all HTML elements in page
  • change all HTML element attributes in page
  • change all CSS styles in page
  • remove existing/add new HTML elements and attributes
  • react to all existing HTML elements on page
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

the nodes in a document make up the page’s

A

DOM tree

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

DOM tree describes

A

relationships among elements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

nodes are related to each other through

A

child-parent relationships

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

t/f: a node can have multiple children and multiple parents

A

false
multiple children, only one parent

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

nodes with same parent node are

A

siblings

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

html node in dom tree is called

A

root node, which is parent node of all HTML elements in a page

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

finding HTML elements in Java
(all document.)

A

getElementById, getElementsByTagName, getElementsByClassName

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

return all p elements as an array inside myElement

A

var x = myElement.document.getElementsByTagName(“p”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

return all elements with class=”major”

A

var x = document.getElementsByClassName(“major”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

finding html elements by css selectors
- p elements with class intro

A

var x = document.querySelectorAll(“p.intro”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

DOM has collections-

A

groups of related objects on a page

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

DOM collections examples

A

document.links/document.anchors, document.images, and document.forms

17
Q

DOM collection’s length property specifies

A

the number of items in the collections

18
Q

document.images[1]

A

second image in page

19
Q

document.forms.length

A

number of forms in page

20
Q

what is used to access element’s attribute values

A

dot (.) operator

21
Q

use dot operator to access 3 different attributes (get element first)

A

var x = document.getElementById(‘myImage’);
x.src = ‘newpic.jpg’;
x.className=’allpics’;
x.id=’alternateimg’;

22
Q

how to get user input value in form input element called fullName

A

var x = document.forms[0];
var y = x.fullName.value;

23
Q

node properties

A

parentNode, childNodes[nodenumber], firstChild, lastChild, nextSibling, previousSibling

24
Q

t/f: a child/sibling node can be a whitespace

25
use HTML DOM tree of objects (slide 12). get the body element, head element, and a element.
body: document.getElementsByTagName("h1")[0].parentNode head: document.getElementsByTagName("html")[0].firstChild a element document.getElementsByTagName("h1")[0].previousSibling
26
4 ways to change HTML elements
.innerHTML, .attribute, .setAttribute, .style.property
27
element.innerHTML = new html content
change the inner HTML of an element
28
element.setAttribute(what are two inputs?)
(attribute, value)
29
element.attribute = ?
new value
30
before changing html elements, you must
get element by id
31
adding and deleting elements (document.____(element))
createElement, removeChild, appendChild, replaceChild
32
removechild, appendchild, and replace child are not
document methods. they can be used with any parent element object
33
2 ways to add event handler, which is recommended
.addEventListener("click", myFunction, false); .onclick = myFunction(){} first is recommended