98-382 Exam QuestionsBrowse all questions from this exam

98-382 Exam - Question 4


HOTSPOT -

You are designing a web page that contains a list of animals. The web page includes a script that outputs animals from a list.

You create the following HTML to test the script:

Exam 98-382 Question 4

You need to create a function that will display the list of animals, including any formatting, in the div element.

How should you complete the code? To answer, select the appropriate code segments in the answer area.

NOTE: Each correct selection is worth one point.

Hot Area:

Exam 98-382 Question 4
Show Answer
Correct Answer:
Exam 98-382 Question 4

References: https://www.w3schools.com/jsref/met_element_getelementsbytagname.asp

Discussion

8 comments
Sign in to comment
ak9797
Nov 17, 2020

the First answer should be getElementsByTagName("li")

kimdo7
Feb 5, 2021

It is correct because it will give you a list/array of 3 li

PallaviSos
Jul 4, 2021

the answer should be document.getElementById("list").innerHTML +=list[i].innerText;

w35l3y
Jul 4, 2021

getElementsByTagName("li") getElementById innerHTML

123nickname123
Mar 30, 2021

Can someone explain this to me? Why are there two sets of paranthesis one after the other?

computercat
Sep 23, 2021

function showList() { var list = document.getElementsByTagName("ul"); for (var i = 0; i < list.length; i++) { document.getElementById("list").innerHTML += list[i].innerHTML; }}

ak9797
Nov 17, 2020

nevermind my comment

learning_weber
Jan 21, 2021

Last Line : document.getElementByTagName("li")("list").innerHTML += list[i].innerText

kimdo7
Feb 5, 2021

I dont think this is valid *document.getElementByTagName("li")("list").innerHTML*

computercat
Sep 23, 2021

agree, this doesn't work

computercat
Sep 23, 2021

agree, this doesn't work

ClauDia
Jun 24, 2021

function showlist(){ var list = document.getElementsByTagName("ul"); console.log(list); for(var i=0; i<list.length; i++){ document.getElementById("list").innerHTML += list[i].innerHTML + " "; } }