Export (0) Print
Expand All
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.

nodeName property

Gets the name of a particular type of node.

Syntax

JavaScript

p = object.nodeName

Property values

Type: String

tagName

The name of the element. This name is also available through the tagName property.

attrName

The name of the attribute, where the node is an attribute object.

#text

The node is a TextNode object.

Standards information

Examples

The following code example uses the nodeName property to obtain the name of an element.


<!DOCTYPE html>
<html>

<head>
  <title>nodeName</title>
</head>

<body>
  <ul id="oList">
    <li>List Item 1</li>
    <li>List Item 2</li>
    <li>List Item 3</li>
  </ul>
  <script>
    // Returns the element name 'LI' of the list item labeled 'List Item 2'.
    var sName = document.getElementById('oList').childNodes[1].nodeName;
    console.log(sName);
  </script>
</body>

</html>

See also

a
abbr
address
area
attribute
b
base
bdo
bgSound
blockQuote
body
br
button
caption
cite
code
col
colGroup
comment
dd
del
dfn
div
dl
documentType
dt
em
embed
fieldSet
form
frame
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
map
menu
object
ol
option
p
pre
ProcessingInstruction
q
s
samp
script
select
small
span
strong
sub
sup
table
tBody
td
textArea
TextNode
tFoot
th
tHead
title
tr
u
ul
var
nodeType
About the W3C Document Object Model

 

 

Show:
© 2014 Microsoft