Single Choice Easy

QWhat would the following JavaScript code produce?

<p>1</p>
<p>2</p>
<p>3</p>
function myFunction() 
{
   var l = document.getElementsByTagName("P").length;
   alert(l);
}

ID: #5098 Javascript DOM & Event Handling MCQ 152 views
Question Info
#5098Q ID
EasyDifficulty
Javascript DOM & Event Handling MCQTopic

Choose the Best Option

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

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

Explanation

The HTMLCollection's length property returns the number of elements it contains.
When you wish to iterate through an HTMLCollection, this element is helpful.

Share This Question

Challenge a friend or share with your study group.