書式
obj.nodeName
対応
[IE5〜][Firefox 1〜][Safari 1〜][Opera 8〜][Netscape 6〜]
説明
ノードの名前を返します。
| 属性 | 属性名 |
| CDATAセクション | #cdata-section |
| コメント | #comment |
| ドキュメント | #document |
| ドキュメントフラグメント | #document-fragment |
| 文書型宣言 | ドキュメントタイプ名 |
| 要素 | 要素名 |
| 実体 | 実体名 |
| 実体参照 | 実体参照名 |
| 記法 | 記法名 |
| 処理命令 | ターゲット |
| テキスト | #text |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=shift_jis">
<title>Sample</title>
<script type="text/javascript"><!--
function check() {
var obj = document.getElementById("pBox");
var typ = obj.firstChild.nodeName;
alert(typ);
var typ = obj.firstChild.firstChild.nodeName;
alert(typ);
}
// --></script>
</head>
<body bgcolor="#fffff0">
<h1>nodeName</h1>
<form>
<input type="button" id="myButton" value="Click" onClick="check()">
</form>
<div id="pBox"><span class="abc">text1</span><div id="subBox">text2</div></div>
</body>
</html>