applyElement method
Inserts the specified element as a child or parent of the current element.
This method is only supported by Internet Explorer, use the appendChild or insertBefore method to add an element as a child to an element.
Syntax:
You can find the related objects in the Supported by objects section below.
Parameters:
Required. Reference to the element to add. | |||||||||||||||||||||||
Optional. String that indicates whether the specified element needs to be inserted as a child or as the parent of the current element.
One of the following values:
|
Return value:
Returns the inserted element.
Example HTML code 1:
This example illustrates the use of the applyElement method.
|
||||
<head> <script type="text/javascript"> function ApplyAsChild () { var div = document.getElementById ("myDiv"); if (div.applyElement) { var newElem = document.createElement ("button"); div.applyElement (newElem, "inside"); } else { alert ("Your browser does not support this example!"); } } function ApplyAsParent () { var list = document.getElementById ("myList"); if (list.applyElement) { var newElem = document.createElement ("i"); list.applyElement (newElem); } else { alert ("Your browser does not support this example!"); } } </script> </head> <body> <div id="myDiv">text for a button</div> <br /> <button onclick="ApplyAsChild ()">Place the text above on a button</button> <br /><br /><br /> <ul id="myList"> <li>List item 1 <li>List item 2 </ul> <button onclick="ApplyAsParent ()">Make list italic!</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
CommentNode
HTML elements:
a, abbr, acronym, address, applet, area, b, base, basefont, bdo, bgsound, big, blockquote, body, br, button, caption, center, cite, code, col, colgroup, comment, dd, del, dfn, dir, div, dl, dt, em, embed, fieldset, font, form, frame, frameset, h1, h2, h3, h4, h5, h6, head, hr, html, i, iframe, img, input:button, input:checkbox, input:file, input:hidden, input:image, input:password, input:radio, input:reset, input:submit, input:text, ins, isindex, kbd, label, legend, li, link, listing, map, marquee, menu, meta, nobr, noframes, noscript, object, ol, optgroup, option, p, param, plaintext, pre, q, rt, ruby, s, samp, script, select, small, span, strike, strong, style, sub, sup, table, tbody, td, textarea, tfoot, th, thead, title, tr, tt, u, ul, var, wbr, xml, xmp
Related pages:
External links:
User Contributed Comments