Prototype-element-cloneposition
提供:Dev Guides
プロトタイプ-clonePosition()メソッド
このメソッドは、オプションの引数オプションで定義されているように、ソースの位置や寸法を要素に複製します。
構文
element.clonePosition(source[, options]);
これは可能なオプションのリストです-
Name | Default | Description |
---|---|---|
setLeft | true | clones source’s left CSS property onto element. |
setTop | true | clones source’s top CSS property onto element. |
setWidth | true | clones source’s width onto element. |
setHeight | true | clones source’s width onto element. |
offsetLeft | 0 | Number by which to offset element’s left CSS property. |
offsetTop | 0 | Number by which to offset element’s top CSS property. |
戻り値
HTML要素。
例
<html>
<head>
<title>Prototype examples</title>
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
<script>
function clonePosition() {
var firstElement = $('firstDiv');
var secondElement = $('secondDiv');
secondElement.clonePosition( firstElement);
}
</script>
</head>
<body>
<p>Click Clone Position button to see the result.</p>
<div id = "firstDiv">
<p>This is first paragraph</p>
</div>
<div id = "secondDiv">
<p>This is second paragraph</p>
</div>
<br/>
<input type = "button" value = "Clone Position" onclick = "clonePosition();"/>
</body>
</html>