HTML DOM Flashcards

1
Q

get the element with ID “demo” and change its text to “Hello!”

A

document.getElementById(“demo”).innerHTML = “Hello!”;

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

get the first paragraph tag and change its text to “Hello!”

A

document.getElementsByTagName(“p”)[0].innerHTML = “Hello!”;

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

Change the text of the first element that has the class name “test” to “Hello!”.

A

document.getElementsByClassName(“test”)[0].innerHTML = “Hello!”;

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

get the first image with Id “hero” and change its src attribute to “bob.png”

A

document.getElementByID(“hero”).src = “bob.png”;

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

get the input field with Id “greeting” and change its value to “hello!”

A

document.getElementById(“greeting”).value = “Hello!”;

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

get the element with Id “demo” and change its text color to red.

A

document.getElementById(“demo”).style.color = “red”;

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

get the element with Id “demo” and change its font size to 40 pixels.

A

document.getElementById(“demo”).style.fontSize = “40px”;

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

get the element with Id “demo” and hide it

A

document.getElementById(“demo”).style.display = “none”;

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

get the element wth Id “demo” and add an event listener that calls myFunction when clicked

A

document.getElementById(“demo”).addEventListener(“click”, myFunction);

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