Exam4Training

Which JavaScript statement results in changing “ Tony” to “Mr. T.”?

Refer to the HTML below:

<div id=”main”>

<ul>

<li>Leo</li>

<li>Tony</li>

<li>Tiger</li>

</ul>

</div>

Which JavaScript statement results in changing “ Tony” to “Mr. T.”?
A . document.querySelectorAll(‘$main $TONY’).innerHTML = ’ Mr. T. ’;
B . document.querySelector(‘$main li:second-child’).innerHTML = ’ Mr. T. ’;
C . document.querySelector(‘$main li.Tony’).innerHTML = ’ Mr. T. ’;
D . document.querySelector(‘$main li:nth-child(2)’),innerHTML =’ Mr. T. ’;

Answer: D

Exit mobile version