- Prototype 教程
- Prototype - 首頁
- Prototype - 簡要概覽
- Prototype - 實用功能
- Prototype - 實用方法
- Prototype - 元素物件
- Prototype - 數字處理
- Prototype - 字串處理
- Prototype - 陣列處理
- Prototype - 雜湊處理
- Prototype - 基本物件
- Prototype - 模板
- Prototype - 列舉
- Prototype - 事件處理
- Prototype - 表單管理
- Prototype - JSON 支援
- Prototype - AJAX 支援
- Prototype - 表達範圍
- Prototype - 定期執行
- Prototype 實用資源
- Prototype - 快速指南
- Prototype - 實用資源
- Prototype - 討論
Prototype - clonePosition() 方法
此方法根據可選引數選項,克隆了 source 元素在 element 上的位置和/或維度。
語法
element.clonePosition(source[, options]);
以下是可能的選項的列表 −
| 名稱 | 預設值 | 說明 |
|---|---|---|
| setLeft | true | 將 source 的左 CSS 屬性克隆到 element 中。 |
| setTop | true | 將 source 的頂部 CSS 屬性克隆到 element 中。 |
| setWidth | true | 將 source 的寬度克隆到 element 中。 |
| setHeight | true | 將 source 的寬度克隆到 element 中。 |
| offsetLeft | 0 | element 的左 CSS 屬性的偏移量。 |
| offsetTop | 0 | element 的頂部 CSS 屬性的偏移量。 |
返回值
一個 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>
輸出
prototype_element_object.htm
廣告