MCQ Single Best Answer 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 128 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: Option C

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.