Retrieves the number of immediate child nodes of the current element or a zero if the element does not contain any child nodes. childElementCount does not return all child nodes, only child nodes that are nodeType =1, or element nodes.

Standards information

Remarks

As of Microsoft Internet Explorer 5 and later, the option elements are part of the all collection. For earlier versions, you can gain access to these elements by applying the options collection to the select element.

You can create new option elements dynamically with the document.createElement method, but you cannot change properties until the new element is added to a select object. Or, you can create fully formed elements by using the Option object, as follows:

You can add option elements only to a select element that is located in the same window where the option elements are created.

Except for background-color and color, style settings applied through the style object for the option element are ignored. In addition, style settings applied directly to individual options override those applied to the containing select element as a whole.

Examples

This example uses the option element to create individual items in a drop-down list box.