Javascriptをはじめ、Ajax、jQueryの著書多数のガイドが、何かと最近騒がれているJa…
北欧好きが、愛用の北欧モノを見せ合うコミュニティ
Javascript関連情報
更新日:2004年03月08日
DOM(Document Object Model)の仕様にそってサンプルを連載します。今回はNodeインターフェイスのnodeNameです。
| Interface | nodeName | nodeValue | attributes |
|---|---|---|---|
Attr |
アトリビュート名( Attr.nameと同じ) |
Attr.valueと同じ |
null |
CDATASection |
"#cdata-section" |
CharacterData.dataと同じ, CDATA セクション |
null |
Comment |
"#comment" |
CharacterData.dataと同じ, コメント |
null |
Document |
"#document" |
null |
null |
DocumentFragment |
"#document-fragment" |
null |
null |
DocumentType |
document type 名 DocumentType.name |
null |
null |
Element |
タグ名 Element.tagName |
null |
NamedNodeMap |
Entity |
エンティティ名 entity name | null |
null |
EntityReference |
参照されるエンティティ名 entity referenced | null |
null |
Notation |
表記法名 notation name | null |
null |
ProcessingInstruction |
ターゲット ProcessingInstruction.target |
ProcessingInstruction.dataと同じ |
null |
Text |
"#text" |
CharacterData.dataと同じ, テキストノード |
null |
test1test2
<p id="pid"><i>test1</i><b>test2</b></p>
<form>
<input type = "button"
value = "クリックしてください"
onclick = "
oj = document.getElementById('pid')
alert( oj.firstChild.nodeName )
">
</form>
クリックすると、<p id="pid">の最初の子ノード <i>test1</i> のノードネーム(タグ名「I」)が表示されます。文字列1test1test2
<p id="pid2">文字列1<i>test1</i><b>test2</b></p>
<form>
<input type = "button"
value = "クリックしてください"
onclick = "
oj = document.getElementById('pid2')
alert( oj.firstChild.nodeName )
">
クリックすると、<p id="pid">の最初の子ノード 文字列1 のノードネーム(#text)が表示されます。
<script>
<!--
function big(oj){
if( oj.nodeName == 'SPAN' )
oj.style.fontSize = "20px"
}
function sml(oj){
if( oj.nodeName == 'SPAN' )
oj.style.fontSize = "1em"
}
//-->
</script>
<div onmouseover = "big(this)"
onmouseout = "sml(this)">DIV</div>
<div onmouseover = "big(this)"
onmouseout = "sml(this)">DIV</div>
<span onmouseover = "big(this)"
onmouseout = "sml(this)">SPAN</span>
<div onmouseover = "big(this)"
onmouseout = "sml(this)">DIV</div>
マウスカーソルが触れると spanタグ の時だけフォントサイズが大きくなります 人気Javascriptランキング
Powered by 価格.com
北欧好きが、愛用の北欧モノを見せ合うコミュニティ