Preview

08 - Manipulating Creating HTML Elements

 1. It is possible to use Javascript to manipulate the HTML elements in the BODY section of your HTML

  TRUE

  FALSE

 2. When a web page is loaded, the browser creates a Document Object Model of the page.
With the HTML DOM, JavaScript can access and change all the elements of an HTML document

  TRUE

  FALSE

 3. Fill in the blanks in the following excerpt.
The HTML DOM can be accessed with JavaScript (and with other programming languages).

In the DOM, all HTML elements are defined as objects.

The programming interface is the properties and methods of each object.

A _________ is a value that you can get or set (like changing the content of an HTML element).

A  __________ is an action you can do (like add or deleting an HTML element).

  property / method

  code / script

  variable / script

  method / property

 4. All of the following methods are ways of using JavaScript to manipulate the HTML elements in the BODY section
createElement
createTextNode
appendChild
insertBefore

  TRUE

  FALSE

 5. Which statement best describes what is happening in the following code?
<html>
<body>

<p id="demo"></p>

<script>
document.getElementById("demo").innerHTML = "Hello World!";
</script>

</body>
</html>

  In this example all the text on the page is being changed to 'demo'

  In this example, getElementById is an ID number that is being changed

  None of these options are correct

  This example changes the content (the innerHTML) of the

element with id="demo":

 6. In the example above, getElementById is a property while innerHTML is a method.

  TRUE

  FALSE

 7. What does the following do?
document.getElementsByTagName(name)

  Find elements by tag name

  changes the attribute value of an HTML element

  changes the style of an HTML element

  Find elements by class name

 8. What does the following do?
document.getElementsByClassName(name)

  Find elements by class name

  changes the attribute value of an HTML element

  changes the style of an HTML element

  Find elements by tag name

 9. What does the following do?
element.attribute = new value

  changes the style of an HTML element

  changes the attribute value of an HTML element

  Find elements by class name

  Find elements by tag name

 10. In the following code, we have two arguments (variables), separated by a comma. The first argument is the new HTML element itself. The second argument is a location for the new element.
insertBefore( newPara, getFooter )

  FALSE

  TRUE