length

ページ上のリンク総数を返します。

構文

document.links.length

例文

<html>
 <head>
  <title>length</title>
  <script type="text/javascript"><!--
  window.onload = function () {
   var n = document.links.length;
   document.getElementById("result").innerHTML = n;
  }
  // --></script>
 </head>
 <body>
 <ul>
  <li><a href="http://www.openspc2.org/">OpenSpace</a>
  <li><a href="http://www.google.co.jp/">Google</a>
 </ul>
 <div id="result"></div>
 </body>
</html>

関連記事

スポンサーリンク

EclipseでAndroidプロジェクトを作る方法

ホームページ製作・web系アプリ系の製作案件募集中です。

上に戻る