Single Choice Easy

QWhat would the following JavaScript code produce?

<p>1</p>
<p>2</p>
<p>3</p>
function myFunction() 
{
    var x = document.getElementsByTagName("P").item(0);
    alert(x.innerHTML);
}

ID: #5097 Javascript DOM & Event Handling MCQ 102 views
Question Info
#5097Q ID
EasyDifficulty
Javascript DOM & Event Handling MCQTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A 1
  • B 3
  • C 2
  • D error
Correct Answer

Explanation

The element at the specified index in an HTMLCollection is returned by the item object. The function retrieves the HTML content of the document's first p> element.

Share This Question

Challenge a friend or share with your study group.