previousSibling
前のノードを示します。
構文
オブジェクト.previousSibling
例文
<html>
 <head>
  <title>previousSibling</title>
  <script type="text/javascript"><!--
  window.onload = function () {
   var pObj = document.getElementById("sub2").previousSibling;
   document.getElementById("result").innerHTML = pObj.nodeValue;
  }
  // --></script>
 </head>
 <body>
 <div id="result"></div>
 <div id="subBlock"><div id="sub1">Sample <div id="sub2">Text</div></div></div>
 </body>
</html>
関連記事
- parentNode
- nextSibling
- lastChild
- item
- insertBefore
- hasChildNodes
- getElementsByTagName
- getElementsByName
- getElementById
- firstChild
- createTextNode
- document.createElement
- cloneNode
- childNodes
- appendChild
スポンサーリンク







