The insertAdjacentElement Method


The insertAdjacentElement Method

The insertAdjacentElement method enables you to insert a new element into a web page. You can see the support for this method in Table 6.29.

Table 6.29. The insertAdjacentElement Method

Method

NS2

NS3

NS4

NS6

IE3a

IE3b

IE4

IE5

IE5.5

IE6

insertAdjacentElement( position , element )

             

x

x

x

 

Returns: Object

We'll see more about methods such as this one in Chapter 16, where we change web pages on-the-fly . To use this method, you can use the document object's createElement method to create a new element, and then use the insertAdjacentElement to insert the new element next to an existing object. You specify where you want the new element with the position argument, which can take these values:

  • "beforeBegin" . Inserts the element immediately before the object.

  • "afterBegin" . Inserts the element after the start of the object (but before all other content in the object).

  • "beforeEnd" . Inserts the element immediately before the end of the object (but after all other content in the object).

  • "afterEnd" . Inserts the element immediately after the end of the object.

This method returns the element inserted.



Inside Javascript
Inside JavaScript
ISBN: 0735712859
EAN: 2147483647
Year: 2005
Pages: 492
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net