EN
이 콘텐츠는 한국어로 제공되지 않아 영어 버전으로 표시됩니다.

nodeValue property

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.


<!DOCTYPE html>

<html>
<head>
  <title>nodeValue</title>
</head>
<body>
  <p>Click the bulleted list:</p>
  <ul>
    <li>Old Node Value</li>
  </ul>
  <script>
    document.getElementsByTagName('li')[0].addEventListener('click', fnChangeValue, false);

    function fnChangeValue(evt) {
      var li = evt.target;
      var textNode = li.childNodes[0];

      textNode.nodeValue = "New Node value";
    }
  </script>
</body>
</html>

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=email
input type=file
input type=hidden
input type=image
input type=number
input type=password
input type=radio
input type=range
input type=reset
input type=search
input type=submit
input type=tel
input type=text
input type=url
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

 

 

표시:
© 2014 Microsoft