返回到:Prototype – 元素对象
该方法将元素变成一个相对定位的元素,而不改变它在页面布局中的位置。
语法
element.relativize();
返回值
返回一个 HTML 元素。
例子
HTML
x
26
26
1
<html>
2
<head>
3
<title>Prototype examples</title>
4
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
5
6
<script>
7
function changetoRel() {
8
node = $("firstDiv");
9
node.style.fontSize = '20px';
10
11
// node.style.position = 'relative';
12
node.relativize();
13
node.style.border = '1px dashed #f00';
14
node.style.left = '100px';
15
}
16
</script>
17
</head>
18
19
<body>
20
<div id = "firstDiv" style = "position:absolute;top:100px;">
21
<p>This is first paragraph</p>
22
</div>
23
<br />
24
<input type = "button" value = "Make Relative" onclick = "changetoRel();"/>
25
</body>
26
</html>
返回到:Prototype – 元素对象
阅读剩余 39%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/9042.html