The length Property


The length Property

We've already used the length property, which just returns the number of items in an array or collection. You can see the support for this property in Table 5.33.

Table 5.33. The length Property

Property

NS2

NS3

NS4

NS6

IE3a

IE3b

IE4

IE5

IE5.5

IE6

length

x

x

x

x

x

x

x

x

x

x

 

Read-only

 

Type: Integer

Here's an example from earlier in this chapter where we're using the length property of the children collection to loop over all the child HTML elements in a form:

(Listing 05-05.html on the web site)
 <HTML>      <HEAD>          <TITLE>Using the children Property</TITLE>      </HEAD>      <BODY>          <H1 NAME="header1">Using the children Property</H1>          <FORM NAME="form1">              <INPUT NAME="button1" TYPE="BUTTON" ONCLICK="alerter()" VALUE="Click Me!">              <INPUT NAME="text1" TYPE="TEXT">          </FORM>          <SCRIPT LANGUAGE="JavaScript">              <!--  for(var loopIndex=0; loopIndex < form1.children.length; loopIndex++){   document.write(form1.children[loopIndex].name + "<BR>")   }  // -->          </SCRIPT>      </BODY>  </HTML> 


Inside Javascript
Inside JavaScript
ISBN: 0735712859
EAN: 2147483647
Year: 2005
Pages: 492
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net