• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Quiz

Test your knowledge of JavaScript's advanced DOM features by answering the following questions.

Questions

1:If para1 is the DOM object for a paragraph, what is the correct syntax to change the text within the paragraph to “New Text”?
  1. para1.value="New Text";

  2. para1.firstChild.nodeValue="New Text";

  3. para1.nodeValue="New Text";

A1: b. The actual text is the nodeValue attribute of the text node, which is a child of the paragraph node.
2:Which of the following DOM objects never has a parent node?
  1. body

  2. div

  3. document

A2: c. The document object is the root of the DOM object tree, and has no parent object.
3:Which of the following is the correct syntax to get the DOM object for a heading with the identifier head1?
  1. document.getElementById("head1")

  2. document.GetElementByID("head1")

  3. document.getElementsById("head1")

A3: a. getElementById has a lowercase “g” at the beginning, and a lowercase “d” at the end, contrary to what you might know about normal English grammar.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint