What will be the output of the following JavaScript code? [code] <p>1</p> <p>2</p> <p>3</p> function myFunction() { var l = document.getElem

What will be the output of the following JavaScript code?
Code:
<p>1</p>
<p>2</p>
<p>3</p>
function myFunction() 
{
   var l = document.getElementsByTagName("P").length;
   alert(l);
}
A. 1
B. 2
C. 3
D. Error
 
Answer: c
Explanation: The length property returns the number of elements in a HTMLCollection. This element is useful when you want to loop through a HTMLCollection.
 

Tìm kiếm

Back
Top