add Method

DHTML, HTML, & CSS

 
Click to return to the DHTML, HTML & CSS home page    
addBehavior Method     DHTML Methods    

add Method


Adds an element to the collection.

Syntax

object.add(oElement [, iIndex])

Parameters

oElementRequired. Object that specifies the element to add to the collection.
iIndexOptional. Integer that specifies the index position in the collection where the element is placed. If no value is given, the method places the element at the end of the collection.

Return Value

No return value.

Remarks

Before you can add an element to a collection, you must create it first by using the createElement method.

The add method can be used on the AREA object only after the page loads. If the method is applied inline, a run-time error occurs.

Example

This example uses the add method to insert an object into the options collection of a SELECT object.

<SELECT ID="oSelect">
  <OPTION VALUE="1">One</OPTION>
</SELECT>

<SCRIPT>
var oOption = document.createElement("OPTION");
oSelect.options.add(oOption);
oOption.innerText = "Two";
oOption.Value = "2";
</SCRIPT>

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
Version data is listed when the mouse hovers over a link, or the link has focus.
areas, controlRange, options

See Also

remove


Back to topBack to top

Did you find this topic useful? Suggestions for other topics? write us!Internet Link

© 1999 microsoft corporation. all rights reserved. terms of useInternet Link.