document.images.length …… ドキュメント内にある画像の数を参照する
広告
イメージオブジェクトのlengthプロパティは、ドキュメント内にある画像の数を参照します。
■構文・引数・戻り値
- 構文
- document.images.length
- 戻り値
- ドキュメント内にある画像の数
■使用例
HTML + JavaScriptソース
<script> <!-- var kazu = document.images.length; document.write('この文書内には'); document.write(kazu); document.write('個の画像があります。'); document.write(kazu); document.write('番目の画像は<img src="'); document.write(document.images[kazu-1].src); document.write('">です。'); // --> </script>
↓↓↓
ブラウザ上の表示
■関連項目
document.images.length …… ドキュメント内にある画像の数を参照する
document.イメージ名.src …… 画像ファイルのURLを参照する
document.イメージ名.lowsrc …… 低解像度画像ファイルのURLを参照する
document.イメージ名.name …… 画像のname属性の値を参照する
document.イメージ名.complete …… 画像の読み込みが完了したかどうかを返す
document.イメージ名.width …… 画像の横幅を設定する
document.イメージ名.height …… 画像の高さを設定する
document.イメージ名.hspace …… 画像の水平方向の余白を設定する
document.イメージ名.vspace …… 画像の垂直方向の余白を設定する
document.イメージ名.border …… 画像のボーダーの太さを設定する
document.イメージ名.src …… 画像ファイルのURLを参照する
document.イメージ名.lowsrc …… 低解像度画像ファイルのURLを参照する
document.イメージ名.name …… 画像のname属性の値を参照する
document.イメージ名.complete …… 画像の読み込みが完了したかどうかを返す
document.イメージ名.width …… 画像の横幅を設定する
document.イメージ名.height …… 画像の高さを設定する
document.イメージ名.hspace …… 画像の水平方向の余白を設定する
document.イメージ名.vspace …… 画像の垂直方向の余白を設定する
document.イメージ名.border …… 画像のボーダーの太さを設定する
広告