Module 3 - The DOM Flashcards

1
Q

Which of the following methods would you use in the DOM in order to retrieve information about the source file of an <img></img> element on your page?

setAttribute()

getAttribute()

innerHTML()

none of the above

A

getAttribute()

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

You have an unordered list on your page with an ID of “list1”. You want to assign a variable to that particular object, which of the following lines of code will achieve this?

var list1 =
document.getElementById(“list1”)

var list1 = document.getElementsByTagName(“list1”)

var list1 = document.getElementsByClassName(“list1”)

var list1 =
getElementById(“list1”)

A

var list1 = document.getElementById(“list1”)

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

Which syntax would allow you to write new content into an HTML element using the DOM?

Element.innerHTML

Element.attribute

Element.style

Element.setAttribute

A

Element.innerHTML

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

Which of the following is the proper syntax for add an Event Listener to a button with the id of “mybtn” on the page?

element.addEventListener(“click”, function(){ alert(“Hello World!”); });

element.addEventListener(“onmouseover”, function(){ alert(“Hello World!”); });

element.addEventListener(“onclick”, function(){ alert(“Hello World!”); });

element.addEventListeners(“click”, function(){ alert(“Hello World!”); });

A

element.addEventListener(“click”, function(){ alert(“Hello World!”); });

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

Which of the following could you use to display the title of a document using the DOM and JavaScript?

Document.heading

Document.title

Document

Document.getElementById

A

Document.title

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

Which of the following would be the correct code for determining the number of links that were contained on page?

Document.getLinks

Document.getAnchors

Document.anchors.length

None of the above

A

None of the above

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

Which of the following should you add to the code on a page if you wanted to create a button that changed styles when it was clicked?

<button onmouseover=changeStyles()>Click Me!</button>

<button onhover=changeStyles()>Click Me!</button>

<button onclick=changeStyles()>Click Me!</button>

<button onchange=changeStyles()>Click Me!</button>

A

<button onclick=changeStyles()>Click Me!</button>

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