add method

Adds an element to the areas, controlRange, or options collection.


HRESULT retVal = object.add(element, before);


  • element [in]
    Type: [IHTMLElement](aa752279(v=vs.85).md)

    Pointer to an IHTMLElement interface that specifies the element to add to the collection.

  • before [in, optional]
    Type: VARIANT

    VARIANT of type VT_I4 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.

    Internet Explorer 8 and later. VARIANT of type VT_DISPATCH that specifies an element to insert before, or NULL to append the object to the collection.

Return value


If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Standards information


This method adds an option element to a select block.

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

See also