Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following code: <p id=\"demo\"></p> <script> document.getElementByI

ID: 3742618 • Letter: C

Question

Consider the following code:

<p id="demo"></p>

<script>
document.getElementById("demo").innerHTML = "Hello World!";
</script>

Select all the statements below that are false for the code above (hint: there are only 4 false statements):

** REMEMBER YOU ARE LOOKING FOR INCORRECT OR FALSE STATEMENTS **

A.

innerHTML is a method of the <p> DOM object referenced by the “demo” id

B.

getElementById("demo") is a method of the Document DOM object referenced by the “document” id

C.

The <p> HTML element will be a DOM object that will be modified when the code in the <script> is run

D.

The DOM Tree of Objects indicates that the <p> DOM object is contained in the <body> DOM element which is contained in the <html> DOM element which is contained in the Document DOM object

E.

It is a dynamic web page because the javascript changes the content when the page is displayed

F.

The DOM Tree of Objects indicates that the <p> DOM object is contained in the <script> DOM element

G.

getElementById("demo") is a property of the Document DOM object referenced by the “document” id

H.

The = sign in the code will replace the value in the innerHTML property with the value Hello World

I.

If the <p id="demo"></p> was placed after the </script> tag, then Hello World! would still be displayed on the page. It doesn’t matter where the HTML element is since the javascript is executed after the page is loaded and the DOM objects are created.

J.

Before the code is run the value of the innerHTML property in the DOM object with id demo is "" (the empty string or no characters)

K.

innerHTML is a property of the <p> DOM object referenced by the “demo” id

L.

The id attribute “demo” in the <p> HTML element becomes a property of the DOM object

Explanation / Answer

False or Incorrect statements are:

A -> Because innerHTML is not a method. Its a property because it is used to change the content of a HTML element.

F -> Because <p> is different HTML element and <script> is another HTML element.

G -> Because getElementById() is not a property, Its a method that defines an action that we are doing on a HTML element.

I -> False. It won't display anything if we place <script> before <p>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote