
原型 - 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>
輸出
prototype_element_object.htm
廣告