canHaveChildren property
[This documentation is preliminary and is subject to change.]
Gets a value indicating whether the object can contain child objects.
Syntax
| JavaScript | |
|---|
Property values
Type: Boolean
VARIANT_FALSE (false)
-
The object cannot be a parent to child objects.
VARIANT_TRUE (true)
-
The object can be a parent to child objects.
Remarks
Objects do not have to contain children for the canHaveChildren property to return true. This property is useful in determining whether objects can be appended as children.
Examples
This example uses the canHaveChildren property to add a new object to the first element in a document that can contain children.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/canHaveChildren.htm
<SCRIPT>
window.onload=fnInit;
function fnInit(){
var oNewObject=document.createElement("SPAN");
var oNewText=document.createTextNode("Test");
oNewObject.appendChild(oNewText);
for(var i=0;i<document.all.length;i++){
if(document.all[i].canHaveChildren==true){
document.all[i].appendChild(oNewObject);
break;
}
}
}
</SCRIPT>
<INPUT TYPE=button VALUE="Add Child" onclick="fnAddChild()">
<DIV ID=oGrandParent STYLE="background-color: #CFCFCF;">
<WBR>WBR - </WBR>
<BR>
<NOBR>NOBR - </NOBR>
<P>P - <s/P>
</DIV>
See also
- a
- abbr
- acronym
- address
- applet
- area
- article
- aside
- b
- base
- baseFont
- bgSound
- big
- blockQuote
- body
- br
- button
- caption
- center
- cite
- code
- col
- colGroup
- comment
- custom
- dd
- del
- dfn
- dir
- div
- dl
- dt
- em
- embed
- fieldSet
- figcaption
- figure
- font
- footer
- form
- frame
- frameSet
- head
- header
- hgroup
- hn
- hr
- html
- i
- iframe
- img
- input type=button
- input type=checkbox
- input type=file
- input type=hidden
- input type=image
- input type=password
- input type=radio
- input type=reset
- input type=submit
- input type=text
- ins
- isIndex
- kbd
- label
- legend
- li
- link
- listing
- map
- mark
- marquee
- menu
- nav
- nextID
- noBR
- noFrames
- noScript
- object
- ol
- option
- p
- plainText
- pre
- q
- rt
- ruby
- s
- samp
- script
- section
- select
- small
- span
- strike
- strong
- style
- sub
- sup
- table
- tBody
- td
- textArea
- tFoot
- th
- tHead
- title
- tr
- tt
- u
- ul
- var
- wbr
- xml
- xmp
- Reference
- appendChild
- createElement
- createTextNode
Build date: 3/8/2012