You create a Web page that contains the following code. (Line numbers are included for reference
only.)
01 <script>
02 function changeColor(c) {
03 document.getElementById(“message”).style.color=c;
04 }
05 </script>
06
07 <p id=”message”>Welcome!</p>
08 <ul id=”color”>
09 <li>Black</li>
10 <li>Red</li>
11 </ul>
You need to ensure that when the user clicks an item in the list, the text color of the Welcome!
message will change. Which declaration should you use?
A.
<ul id=”color”>
<li onclick=”changeColor(this.innerText);”>Black</li>
<li onclick=”changeColor(this.innerText);”>Red</li>
</ul>
B.
<ul id=”color”>
<li onclick=”changeColor(this.style.color);”>Black</li>
<li onclick=”changeColor(this.style.color);”>Red</li>
</ul>
C.
<ul id=”color”>
<li><a onfocus=”changeColor(this.innerText);”>Red</a></li>
<li><a onfocus=”changeColor(this.innerText);”>Black</a></li>
</ul>
D.
<ul id=”color”>
<li><a onfocus=”changeColor(this.style.color);”>Red</a></li>
<li><a onfocus=”changeColor(this.style.color);”>Black</a></li>
</ul>