Prototype-element-getheight

提供:Dev Guides
移動先:案内検索

プロトタイプ-getHeight()メソッド

このメソッドは、計算された要素の高さを見つけて返します。

このメソッドは、インラインスタイルルールまたはCSSスタイルシートで表示がnoneに設定されている要素の正しい値を返します。

返される値はピクセル単位で表されますが、数値のみであることに注意してください。

構文

element.getHeight();

戻り値

計算された要素の高さを返します。

<html>
   <head>
      <title>Prototype examples</title>
      <script type = "text/javascript" src = "/javascript/prototype.js"></script>

      <script>
         function showResult() {
            var height = $('rectangle').getHeight();
            alert("Element height is " +  height );
         }
      </script>
   </head>

   <body>
      <p>Click the button to see the result.</p>

      <div id = "rectangle"
         style = "font-size: 10px; width: 20em; height: 10em">
         <p>This is the paragraph.</p>
      </div>
      <br/>

      <input type = "button" value = "showResult" onclick = "showResult();"/>
   </body>
</html>

出力