Inside JavaScript

The getAdjacentText Method

The getAdjacentText method enables you to get text directly from a web page. You can see the support for this method in Table 6.21.

Table 6.21. The getAdjacentText Method

Method

NS2

NS3

NS4

NS6

IE3a

IE3b

IE4

IE5

IE5.5

IE6

getAdjacentText( position )

             

x

x

x

 

Returns: String

You can use this method to get the text part of an element (without any HTML tags). You pass this method a position argument that indicates where you want to get the text from in relation to the current object; this argument may be set to one of these values:

  • "beforeBegin" . Text is returned from immediately before the element.

  • "afterBegin" . Text is returned from after the start of the element (but before all other content in the element).

  • "beforeEnd" . Text is returned from immediately before the end of the element (but after all other content in the element).

  • "afterEnd" . Text is returned from immediately after the end of the element.

Категории