Module 3 - The DOM Flashcards
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
getAttribute()
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”)
var list1 = document.getElementById(“list1”)
Which syntax would allow you to write new content into an HTML element using the DOM?
Element.innerHTML
Element.attribute
Element.style
Element.setAttribute
Element.innerHTML
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!”); });
element.addEventListener(“click”, function(){ alert(“Hello World!”); });
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
Document.title
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
None of the above
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>
<button onclick=changeStyles()>Click Me!</button>