Hybrid 6 cont. Flashcards
<ul>
<li> id="item-1">HTML for content</li>
<li> id="item-2">CSS for presentation</li>
<li> id="item-3">JavaScript for functionality</li>
</ul>
How can we select all the li elements?
document.getElementsByTagName(“li”)
T/F - getElementbyClassName() and getElementsByTagName() return an array-like list of the matched elements even if the match is for a single element
True
document.getElementsByClassName(“test”).innerHTML= “Hello”;
Will change what?
THe first element that has the class name “test”
T/F - JavaScript only provides one way to add Event Listeners to Elements
False
How can you retrieve an element with the id “first”? 2 ways
document.querySelector(#first)
document.getElementById(“first”)
T/F - Scripting languages can accomplish tasks quickly without concern for machine efficiency because it is interpretable and dynamically typed language
True
What is the first step in adding event handling to your JavaScript code?
Identifying the DOM node the interactive behaviour will be attached to
IF your html code cotains the follow element:
<p> The quick brown fox jumped the fence </p>
The following javascript code will change the color of the paragraph to red?
document.fox.style.color = “red”;
False