- 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
广告