nodeValue Property

MS Office DHTML, HTML & CSS

nodeValue Property


Sets or retrieves the value of a node.

Syntax

HTML N/A
Scriptingobject.nodeValue [ = sValue ]

Possible Values

sValueString that specifies the node value or null.

The property is read/write with no default value.

Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see dynamic propertiesInternet Link.

Remarks

If the object is a TextNode, the nodeValue property returns a string representing the text contained by the node.

If the object is an Attribute object retrieved from the attributes collection, the nodeValue property returns the value of the attribute if it has been specified, or null otherwise.

If the object is an element, the nodeValue returns null. Use the nodeName property to determine the element name.

Example

This example alters the text of the specified list item by setting the nodeValue property of the text node contained by that list item.

<SCRIPT>
function fnChangeValue(oList, iItem, sValue){
   // only perform the operation on lists
   if (oList.nodeName != "UL" && oList.nodeName != "OL")
      return false;

   // only perform the operation if the specified index is 
   // within the acceptable range of available list items
   if (iItem > oList.childNodes.length -1)
      return false;

   // get a reference to the specified list item
   var oLI = oList.childNodes(i);
   if (!oLI)
      return false;

   // get a reference to the text node contained by the list item
   var oText = oLI.childNodes(0);
   // ensure that the node is a text node
   if (oText.nodeType != 3)
      return false;

   oText.nodeValue = sValue;
   return true;
}
</SCRIPT>

<UL ID="oList" onclick="fnChangeValue(this, 0, 'New Node value')">
<LI>Old Node Value
</UL>

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
Version data is listed when the mouse hovers over a link, or the link has focus.
A, ACRONYM, ADDRESS, APPLET, AREA, Attribute, 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, HEAD, 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, KBD, LABEL, LEGEND, LI, LINK, LISTING, MAP, MARQUEE, MENU, NEXTID, OBJECT, OL, OPTION, P, PLAINTEXT, PRE, Q, S, SAMP, SCRIPT, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TextNode, TFOOT, TH, THEAD, TITLE, TR, TT, U, UL, VAR, XMP

Back to topBack to top

Did you find this topic useful? Suggestions for other topics? write us!Internet Link

© 1999 microsoft corporation. all rights reserved. terms of useInternet Link.