Microsoft
98-382 · Question #30
You are designing a web page with a script that must dynamically change the content of a paragraph element to display the value returned by the function randomQuote(). You have created the following…
The correct answer is C. document.getElementById("tester").innerHTML = randomQuote(). See the full explanation below for the reasoning.
Question
You are designing a web page with a script that must dynamically change the content of a paragraph element to display the value returned by the function randomQuote().
You have created the following code. Line numbers are included for reference only.
01 <!DOCTYPE html>
02 <html>
03 <body>
04 <p id="tester" onclick="changeText()">Click to change the content.</p>
05 <input type="button" value="Change Text" onclick="changeText()" />
06 <script>
07 function changeText() {
08 }
09 </script>
10 </body>
11 </html>
Which code segment should you use at line 08?
Options
- Adocument.getElementById("tester").value = randomQuote();
- Bdocument.getElementById("tester").title = randomQuote();
- Cdocument.getElementById("tester").innerHTML = randomQuote();
- Ddocument.getElementById("tester").script = randomQuote();
How the community answered
(40 responses)- A5% (2)
- B13% (5)
- C80% (32)
- D3% (1)
Community Discussion
No community discussion yet for this question.