nodeValue property

Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
1 out of 6 rated this helpful - Rate this topic

Gets or sets the value of a node.

Syntax

JavaScript

p = object.nodeValue

Property values

Type: Variant

the node value or null.

Standards information

Remarks

If the object is a TextNode object, the nodeValue property returns a string that represents the text that the node contains.

You cannot use expressions to change the nodeValue of a TextNode object.

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.

Examples

The following code example alters the text of the specified list item by setting the nodeValue property of the text node that is 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>

See also

a
abbr
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
documentType
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
ProcessingInstruction
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
Reference
value
Conceptual
About the W3C Document Object Model

 

 

Send comments about this topic to Microsoft

Build date: 11/27/2012

Did you find this helpful?
(1500 characters remaining)

Community Additions

© 2013 Microsoft. All rights reserved.