"Text/javascript">Window.onload =function () {var Topmenus = GetClass (‘Li‘,‘Topmenu‘);Forvar i=0;i < Topmenus.length; i++{alert (topmenus[i].innerhtml);}} function GetClass (tagname,classname)//Gets the element with the tag name tagname, class name classname{if (document.getelementsbyclassname)//Support this function{ReturnDocument.getelementsbyclassname (ClassName); }Else{var tags=document.getelementsbytagname (tagName);//Get tagsvar tagarr=[];//Used to return an element with the class name classnameForvar i=0;i < Tags.length; i++) {if (Tags[i].class = =ClassName) {Tagarr[tagarr.length] = tags[i];//Save an element that satisfies a condition} }ReturnTagarr; }}</script>"Nav"><liclass="Topmenu"><a href="#"> Product introduction </a> <ulclass="Submenu"> <li><a href="#"> Products 1</a></li> <li><a href="#"> Products 2</a></li> <li><a href="#"> Products 3</a></li> <li><a href="#"> Products 4</a></li> <li><a href="#"> Products 5</a></li> <li><a href="#"> Products 6</a></li> </ul></li><liclass="Topmenu"><a href="#"> Service Introduction </a> <ulclass="Submenu"> <li><a href="#"> Service 1</a></li> <li><a href="#"> Service 2</a></li> <li><a href="#"> Service 3</a></li> <li><a href="#"> Service 4</a></li> </ul></li><liclass="Topmenu"><a href="#"> Success Stories </a> <ulclass="Submenu"> <li><a href="#"> Case 1</a></li> <li><a href="#"> Case 2</a></li> <li><a href="#"> Case 3</a></li> <li><a href="#"> Case 4</a></li> </ul></li><liclass="Topmenu"><a href="#"> About Us </a> <ulclass="Submenu"> <li><a href="#"> We 1</a></li> <li><a href="#"> We 2</a></li> <li><a href="#"> We 3</a></li> <li><a href="#"> We 4</a></li> </ul></li><liclass="Topmenu"><a href="#"> Contact Us </a> <ulclass="Submenu"> <li><a href="#"> Contact 1</a></li> <li><a href="# "#" > Contact 3</a> </li> <li><a href= "# "> Contact 4</a></li> <li><a href=" # "#" > Contact 6</a> </li> <li><a href= "# "> Contact 7</a></li> </ul></li></ul></body>
Note that both Getelementsbyclassname and getElementsByTagName have s;
JS can not use int a=1; a=1 with var;
JS Native Package GetClassName () method-ie does not support getelementsbyclassname, so it's up to you to get all the elements with the class name classname