Returns the contents of the TextNode located at the specified position relative to the current element.
You can find the related objects in the Supported by objects section below.
Required. String that specifies the position where the TextNode is located.
One of the following values:
|
Returns the contents of the TextNode element as a string. If no TextNode element is located at the specified position, it returns an empty string.
This example illustrates the use of the getAdjacentText method:
|
||||
<head> <script type="text/javascript"> function FindText (text){ var from = document.getElementById ("searchFrom"); alert (from.getAdjacentText(text)); } </script> </head> <body> far from ... <br /> last text before <div id="searchFrom" style="border:1px solid black"> first text inside <br /> inside <br /> last text inside </div> first text after <br /> far from ... <br /> <button onclick="FindText ('beforeBegin')">Find text before begin</button> <button onclick="FindText ('afterBegin')">Find text after begin</button> <button onclick="FindText ('beforeEnd')">Find text before end</button> <button onclick="FindText ('afterEnd')">Find text after end</button> </body> |
||||
|
||||
Did you find this example helpful?
|
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
User Contributed Comments