I haven’t done any recursive calls in a long time. After reading it, I suddenly woke up! Copy code The code is as follows: Statistics Element nodes <br> var elementName="";<br> function countTotalElement(node)<br> {<br> / //Attribute nodeType value is 2, indicating node attribute <br> ///Comment nodeType value is 8, indicating comment text <br> ///Document nodeType value is 9, indicating Document<br> ///DocumentFragment nodeType value is 11. Indicates Document fragment <br> ///Element The nodeType value is 1, which represents the element node <br> ///Text The nodeType value is 3, which represents the text node <br> var total=0;<br> if(node. nodeType==1) //1 represents the type of node as Element<br> {<br> total ;<br> elementName=elementName node.tagName "rn";<br><br> }<br><br> var childrens=node.childNodes;<br> for(var i=0;i<childrens.length;i )<BR> {<BR> total =countTotalElement(childrens[i]);<BR> } <BR> return total ;<BR> }<BR> Test TR & GT; & LT; TD & GT; & LT; Form Name = "Form1" Action = "Method =" Post "& GT; & LT; alue = " Test" > /tr> Start testing