Prototype-element-relativize

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

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

このメソッドは、ページレイアウト内の位置を変更せずに、要素を相対的に配置された要素に変換します。

構文

element.relativize();

戻り値

HTML要素を返します。

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

      <script>
         function changetoRel() {
            node = $("firstDiv");
            node.style.fontSize = '20px';

           //node.style.position = 'relative';
            node.relativize();
            node.style.border = '1px dashed #f00';
            node.style.left = '100px';
         }
      </script>
   </head>

   <body>
      <div id = "firstDiv" style = "position:absolute;top:100px;">
         <p>This is first paragraph</p>
      </div>
      <br/>
      <input type = "button" value = "Make Relative" onclick = "changetoRel();"/>
   </body>
</html>

出力