Quiz 5, 6 & 7 Flashcards
T/F - Javascript only provides one way to add Event Listeners to Elements
False
how can you retrieve an element with the id “first”?
document.querySelector(“#first”) and document.getElementById(“first”) both work
T/F - The methods getElementsByClassName() and getElementsByTagName() both return an array-like list of the matched elements, even if the match is for a single element.
True
T/F - if your html code contains the following 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
What is the first step in adding event handling to your JavaScript code?
identifying the DOM node the interactive behavior will be attached to
Given the following code:
<ul>
<li>HTML for content</li>
<li>CSS for presentation</li>
<li>JavaScript for functionality</li>
</ul>
how we can select all the li elements?
document.getElementsByTagName(“li”)
document.getElementsByClassName(“test”)[0].innerHTML = “Hello”;
Change the text of the first element that has the class name “test”.
T/F - one of the benefits of scripting language is that it can accomplish the task quickly without concern for machine efficiency because it is interpretable and dynamically typed language
True
T/F - The following code will generate a random number (from 0-99) each time we click the button” Add a number”
<html>
<body>
<script> function addRandomNumber(){ let el = document.createElement("p"); el.innerText = Math.floor(Math.random() * 100); document.body.appendChild(el); } </script>
<button>Add a number</button>
</body>
</html>
True
Which properties are included in the box model?
height, padding, and border
What is the rem unit based on?
The rem unit is relative to the font-size of the root element of the page. In HTML the root element is <html>.
T/F - Given the following rule
. grid {
display: grid;
width:500px;
grid-template-columns:100px 1fr 1fr;
}
The first column will have a width of 100px. The second column will be 150px wide and the third column will be 300px wide.
False
Select the option that is NOT a valid JavaScript Datatype
String
Int
Number
Boolean
Int
T/F - JavaScript is used to add interactive content to Web Sites
True
What will be the result of the JavaScript expression (31 + “ angry polar bears”)
“31 angry polar bears”